如何在其他列表上方创建表格
我想创建一个如下链接所示的用户界面:
http://i53.tinypic.com/sxksx5 .jpg
根据我的说法,可以通过以下方法来做到这一点。
此图像中有两个表格。上表应按以下方式制作:
一个 xml 文件中一行有两个 textview。现在使用 LayoutInflater 来扩展此 UI。使用循环绘制它并根据要求设置文本。
下表应按以下方式制作:
请参阅上面的链接,其中建议使用列表视图制作第二个表格。
现在我很困惑,这可以使用gridvew、tablelayout、listview来实现。我应该更喜欢哪一个,为什么?在我之前的项目中,我几乎在编码中就制作了这种 UI。但我相信 UI 上的一点改变就需要代码上的大量改变。所以我想使用xml来制作当前的UI。但不知道什么方法最好。
I want to create a UI as shown in the below link:
http://i53.tinypic.com/sxksx5.jpg
According to me there can be the following approaches to do it.
There are two tables in this image. The above table should be made in the following way:
One row with two textview in one xml file. Now Inflate this UI using LayoutInflater. Draw It using a loop and set the text according to requirement.
The below table should be made in the following way:
How to make a dynamic table layout using XML
see the above link where It is advised that the 2nd table should be made using the listview.
Now I am confused that this can be made using gridvew, tablelayout, listview. Which one I should prefer and why? In my previous projects I have made this kind of UI almost in the coding. But I believe that a little change in the UI will require lot of change in the code. So I want to make the current UI using the xml. But dont know what approach would be best.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 ListView。对其进行子类化并重载 getItem() 方法以呈现表行的每一列。然后,您可以轻松地将列表视图绑定到数据源。您需要创建一个 XML 布局资源来描述表的一行。
要在另一个表格上方显示一个表格,请将列表视图放入相对布局中,并指定属性以相对于彼此定位它们。
http://developer.android.com/reference/android/widget/ListView.html
http://developer.android.com/resources/tutorials/views/hello-relativelayout.html
I'd suggest using a ListView. Subclass it and overload the getItem() method to render each column of the table row. You can then easily bind the listview to your data sources. you'll need to create an XML layout resource to describe a row of the table.
To show one table above another, put the listviews inside a RelativeLayout and specify attributes to position them relative to each other.
http://developer.android.com/reference/android/widget/ListView.html
http://developer.android.com/resources/tutorials/views/hello-relativelayout.html