关于“动态”创建 GUIS 的问题在安卓上
我正在尝试制作一个 Android 应用程序(我是 Android 编程世界的新手),但在创建 GUI 时遇到问题。
关键是我得到了一些按天划分的数据信息......问题是我不知道,直到我检索信息,GUI 应该显示多少天。
http://img574.imageshack.us/img574/3787/mainscreen.jpg
灰色部分将是一个 TextView,黑色部分将是另一个具有多行的 TextView。
所以,重点是,在不知道确切数量的情况下如何拥有多个 TextView?我想我不能在layout.xml中声明它们
我一直在考虑的唯一解决方案是在布局中创建7对TextView,当我知道确切的数字时,只需使用我必须的,并且不要使用其他的...(这是一个糟糕的解决方案)
你有什么建议?
谢谢您的回答!
I'm trying to make an android app (I'm new in the Android programming world), and I'm having problems creating the GUI.
The point is that I get information of some data that is divided in days... The problem is that I don't know, until I retrieve the information, how many days the GUI should display.
http://img574.imageshack.us/img574/3787/mainscreen.jpg
The grey part will be a TextView, and, also, the black part will be another TextView with multiple lines.
So, the point is, how can I do to have multiple TextView's without knowing before the exact number? I suppose that I can't declare them in the layout.xml
The only solution that I've been thinking about is to create in the layout 7 pairs of TextView and, when I know the exact number, just use what I have to, and don't use the others... (It's a bad solution)
What do you suggest?
Thank you for your answers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该创建一个 ListView,它会为您拥有的项目膨胀 TextView。
您可以使用此示例 如何创建分段 ListView,它看起来与您想要的一模一样。
You should create a ListView, which inflates TextView for the items you have.
You can use this example of how to create sectioned ListView, which will look exactly like you want.
我对 Android 不熟悉,所以其他人可能会提供更好、更具体的建议。
在我熟悉的环境中,显示未知数量的项目的问题是通过不使用每个数据项的一系列显示元素而是使用列表控件来解决的。列表组件将显示您提供的尽可能多的项目,并且通常可以修改为针对不同的数据具有不同的外观,因此您可以灵活地使其按照您想要的方式美观。
I'm not familiar with Android, so other people may offer better, more specific advice.
In the environments I'm familiar with, the problem of displaying an unknown number of items is solved by using not a series of display elements for each data item but a list control. The list component will display as many items as you give it, and can usually be modified to have different appearance for different data, so you're flexible in making it as pretty as you want.
那么你也可以考虑这个,
希望这会有所帮助............
Well you can consider this one also,
Hope this helps...............