android tablelayout trouble, adding views

Haider28

New Member
I am having trouble with \[code\]View leader\[/code\] , I'm not sure what the second parameter is supposed to be\[code\] TableLayout leaderTable = (TableLayout)findViewById(R.id.leaderTable); TableRow tr = new TableRow(this); tr.setId(i); tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); View leader = new View(UserView.this, null, R.id.leaderLayout); TextView number = (TextView)leader.findViewById(R.id.numberView); number.setText(String.valueOf(i+1)); tr.addView(leader); leaderTable.addView(tr);\[/code\]The problem is that my \[code\]TextView\[/code\] is null, despite being a subview of \[code\]leader.\[/code\]Pretty confused about this issue, and this is my XML\[code\]<TableLayout android:id="@+id/leaderTable" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> </TableLayout>\[/code\]do I need to do more with the XML? I don't have need to include the tablerows in it do I?\[code\]R.id.leaderLayout\[/code\] is its own xml file, a linearlayout with that id
 
Back
Top