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

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

问题描述

我学会了如何使用 XML 文件创建 UI.但请帮助我知道如何在不使用 XML 文件的情况下以编程方式完成,尤其是对于 LinearLayout 以外的其他文件.

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

使用下面的创建表格行

TableRow tr=new TableRow(context);

将视图添加到表格行

tr.addView(view);

这里的视图可能是 TextView 或 EditText 或 ect..

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天全站免登陆