Code example for TableRow

Methods: setLayoutParams, addView, setId

0
//            tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
//        } 
        TableLayout tl = (TableLayout) findViewById(R.id.TableLayout1);
 
        // Create a TableRow and give it an ID 
        TableRow tr = new TableRow(this);
        tr.setId(100);
        tr.setLayoutParams(new LayoutParams());
 
        // Create a TextView to house the name of the province 
        TextView labelTV = new TextView(this);
        labelTV.setId(200);
        labelTV.setText("MHI");
        labelTV.setTextColor(Color.BLACK);
        tr.addView(labelTV);
 
        // Create a TextView to house the value of the after-tax income 
        TextView valueTV = new TextView(this);
        valueTV.setId(1);
        valueTV.setText("$0");
        valueTV.setTextColor(Color.BLACK);
        tr.addView(valueTV);
 
        // Add the TableRow to the TableLayout 
        tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    } 
 
Connect your IDE to all the code out there  Get Codota for Java