Android TableLayout以编程方式 [英] Android TableLayout programmatically

查看:71
本文介绍了Android TableLayout以编程方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习了如何使用XML文件创建UI.但是,请帮助我了解如何以编程方式进行操作而不使用XML文件,尤其是除LinearLayout之外的XML文件.

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.

推荐答案

使用以下代码创建TableLayout

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);

将视图添加到表行

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.

这篇关于Android TableLayout以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆