Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TableLayout programmatically

I learned how to create UI using XML file.But please help me to know how to do it programmatically without using XML files especially for other than LinearLayout.

like image 687
RAVITEJA SATYAVADA Avatar asked Dec 02 '22 01:12

RAVITEJA SATYAVADA


1 Answers

Use the following code to create the TableLayout

TableLayout tbl=new TableLayout(context);

Use the below to create the Table row

TableRow tr=new TableRow(context);

add View into table row

tr.addView(view);

here view may be a TextView or EditText or ect..

add Table Row into TableLayout

tbl.addView(tr);

Like that you can add more table rows into Table Layout.

like image 59
Finder Avatar answered Dec 05 '22 00:12

Finder