PiyushMishra PiyushMishra - 1 year ago 173
Android Question

How to add rows dynamically into table layout

I have certain data in sqllite and it update every time whenever, I click on save button and i want to show the data into a table layout for adding more rows for updated data.I have certain code but it show only the updated data replacing previous data and i want to add more rows as the data updated. I know this is only to add one row into table layout but how can i add more rows.

TableLayout tl=(TableLayout)findViewById(R.id.maintable);
TableRow tr1 = new TableRow(this);
tr1.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView textview = new TextView(this);
tl.addView(tr1, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

Answer Source

The way you have added a row into the table layout you can add multiple TableRow instances into your tableLayout object



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download