机器人是否有一个表像适配器的ListView适配器、机器人、有一个、ListView

2023-09-06 02:01:41 作者:/

我用一个ListView显示的项目清单。这些项目是在列和行的表格式。有没有像适配器表,以确保所有的行和列线了?我知道这带来的每列应该多大的复杂性,做什么用切断的文字,和其他的东西。我只是好奇,如果有当前和适配器隐藏了这一任务的地方。或者甚至另一个控制?

I'm using a ListView to show a list of items. These items are in a table format with columns and rows. Is there a table like adapter to make sure all the columns and rows line up? I know this brings in the complexity of how large each column should be, what to do with cut off text, and other things. I'm just curious if there is currently and adapter hiding somewhere for this task. Or maybe even another control?

推荐答案

使用的ListView的一点是要能够通过不创建和布局视图的所有项目的前期扩展到更大的数据集。正因为如此,你的要求从根本上有怎样的ListView工作的冲突 - ListView控件根本不知道该怎么所有的项目将布局,所以没有办法为它自动地确保他们以某种方式排列

The point of using ListView is to be able to scale to larger data sets by not having to create and layout views for all of the items up-front. Because of this, your request fundamentally conflicts with how ListView works -- ListView simply doesn't know how all of its items will layout, so there is no way for it to automatically make sure they align in some way.

您可以确保他们调整自己只是通过适当编写的项目布局。例如,很多时候在UI你将有一个图标后跟标号。如果你确保图标是一个特定的大小,那么所有列表中的项目将调整。如果你正在处理的是更有活力,如文本元素,你可以通过执行前期的特定宽度这些元素做同样的事情。

You can ensure they align yourself just by writing the item layout appropriately. For example, very often in the UI you will have an icon followed by a label. If you ensure the icon is a specific size, then all of the list items will align. If you are dealing with elements that are more dynamic like text, you could do the same thing by enforcing up-front a specific width for those elements.

如果你真的想拥有用户界面动态地计算元件的大小和调整都是基于他们行的,那是什么TableLayout一样。它可以做到这一点,因为它总是有所有元素有布局在一起。如果你想允许滚动的话,你可以用,在一个滚动型像另一个海报建议。要知道,这种做法将很快崩溃为你的行数显著增加。

If you really want to have the UI compute the element sizes dynamically and align all of the rows based on them, that is what TableLayout does. It can do this because it always has all elements there to layout together. If you want to allow scrolling in it, you can wrap that in a ScrollView like another poster suggested. Just be aware that this approach will quickly fall apart as your number of rows increases significantly.