David David - 20 days ago 6
Android Question

How to update tablerow textview?

I have this dynamic tablelayout:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TableLayout
android:id="@+id/main_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dip"
android:layout_weight="1"
android:stretchColumns="1" >
</TableLayout>
</LinearLayout>


and the code:

tl = (TableLayout) findViewById(R.id.main_table);
...
// Create 5 columns to add as table data
TextView labelid = new TextView(this);
labelid.setId(count);
labelid.setTextSize(20);
labelid.setPadding(10, 10, 10, 10);
labelid.setGravity(Gravity.CENTER);
labelid.setText(readxml.getID() + " ");
labelid.setTextColor(Color.BLACK);
tr.addView(labelid);

// Create 5 columns to add as table data
TextView labelname = new TextView(this);
labelname.setId(count);
labelname.setTextSize(20);
labelname.setPadding(10, 10, 10, 10);
labelname.setGravity(Gravity.CENTER);
labelname.setText(readxml.getName() + " ");
labelname.setTextColor(Color.BLACK);
tr.addView(labelname);


So, how can I update 1 row textviews texts?

Answer

I would suggest you to use GridView if it suits your issue, otherwise you may check this answer, it is what you need.

Comments