花式动态列表中的Andr​​oid:TableLayout VS的ListView [英] Fancy dynamic list in Android: TableLayout vs ListView

查看:158
本文介绍了花式动态列表中的Andr​​oid:TableLayout VS的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有是具有不那么琐碎动态列表中,每个记录其中由若干列(文本,按钮)的要求。它看起来应该是这样的:

There is a requirement to have not-so-trivial dynamic list, each record of which consists of several columns (texts, buttons). It should look something like:

Text11 Text12 Button1 Button2
Text21 Text22 Button1 Button2
...

在第一个明显的方式来实现这一目标似乎是 TableLayout 。我期待有在res /布局/ *。xml的指定布局/造型数据,并与从Java code一些数据来填充它(与的ListView ,为其中其可能在*的.xml指定的TextView 项目,并使用其绑定到某些数组 ArrayAdapter )。但是,玩了一会儿后,我都发现可以完全填充 TableLayout 编程。尽管如此,由的TableRow 创建的TableRow 并设置布局的java code直接属性似乎不优雅不够。

At first obvious way to accomplish that seemed to be TableLayout. I was expecting to have layout/styling data specified in res/layout/*.xml and to populate it with some dataset from java code (as with ListView, for which its possible to specify TextView of item in *.xml and bind it to some array using ArrayAdapter). But after playing for a while, all I found to be possible is fully populating TableLayout programatically. Still, creating TableRow by TableRow and setting layout attributes directly in java code doesn't seem elegant enough.

所以,问题是:我是在正确的道路?为 TableLayout 真是最好的完成看法?也许这是更为适当延长的ListView 或别的东西来满足这样的要求?

So the question is: am I at the right path? Is TableLayout really best View to accomplish that? Maybe it's more appropriate to extend ListView or something else to meet such requirements?

推荐答案

使用ListView和ArrayAdapter你可以做更复杂的布局,不仅仅是一个TextView。你可以指定与2 TextViews和2个按钮的的LinearLayout在表的每一行。

Using ListView and ArrayAdapter you can do more complicated layouts than just a TextView. You could specify a LinearLayout with 2 TextViews and 2 Buttons for each row in the List.

这里有一个类似的问题
<一href=\"http://stackoverflow.com/questions/1709166/android-listview-elements-with-multiple-clickable-buttons\">http://stackoverflow.com/questions/1709166/android-listview-elements-with-multiple-clickable-buttons

这篇关于花式动态列表中的Andr​​oid:TableLayout VS的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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