I had wrote this within Oncreate :
Using java Syntax Highlighting
- String[] provinces = new String[13];
- provinces[0] = "Alberta";
- provinces[1] = "British Columbia";
- provinces[2] = "Manitoba";
- provinces[3] = "New Brunswick";
- provinces[4] = "Newfoundland and Labrador";
- provinces[5] = "Northwest Territories";
- provinces[6] = "Nova Scotia";
- provinces[7] = "Nunavut";
- provinces[8] = "Ontario";
- provinces[9] = "Prince Edward Island";
- provinces[10] = "Quebec";
- provinces[11] = "Saskatchewan";
- provinces[12] = "Yukon";
- TableLayout tl = (TableLayout) findViewById(R.id.TableLayout01);
- // Go through each item in the array
- for (int current = 0; current < 13; current++)
- {
- // Create a TableRow and give it an ID
- TableRow tr = new TableRow(this);
- tr.setId(100+current);
- tr.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- // Create a TextView to house the name of the province
- TextView labelTV = new TextView(this);
- labelTV.setId(200+current);
- labelTV.setText(provinces[current]);
- labelTV.setTextColor(Color.BLACK);
- labelTV.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- tr.addView(labelTV);
- // Create a TextView to house the value of the after-tax income
- TextView valueTV = new TextView(this);
- valueTV.setId(current);
- valueTV.setText("$0");
- valueTV.setTextColor(Color.BLACK);
- valueTV.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- tr.addView(valueTV);
- // Add the TableRow to the TableLayout
- tl.addView(tr, new TableLayout.LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
And this in main.xml :
Using xml Syntax Highlighting
- <TableLayout android:id="@+id/TableLayout01"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:stretchColumns="1">
- </TableLayout>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
But no rows are added then i run the program.. Help me with this..


