机器人TableLayout编程机器人、TableLayout

2023-09-14 23:03:40 作者:眼角眉梢都是你

我是新来的机器人的研究与开发。我学会了如何使用XML file.But请帮助我知道该怎么做它来创建用户界面编程,而无需使用XML文件,特别是对超过的LinearLayout

I am new to android developement. 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

推荐答案

使用下面的code创建TableLayout

Use the following code to create the TableLayout

TableLayout tbl=new TableLayout(context);

使用下面的创建表行

TableRow tr=new TableRow(context);

添加视图到表行

add View into table row

tr.addView(view);

下面来看可能是一个TextView或EditText上或等..

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

添加表行到TableLayout

add Table Row into TableLayout

tbl.addView(tr);

就像你可以添加更多的表行到表布局。

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