Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个相当复杂的布局并且有一些布局嵌套。该布局包含 8 个项目,但如果我的 api 响应返回说 32 个项目 id,则希望一遍又一遍地循环相同的 xml 布局并使其可滚动。这可能吗?我考虑过自定义列表视图,但我不确定这是否复杂。
这当然是可能的。我会使用带有自定义适配器的 ListView。您可以将相当复杂的视图作为行放入其中,此外您还可以获得 ListView 的所有性能优势。
否则,您可以很容易地以编程方式完成所有操作。
伪代码:
for (Item item : yourResponseItems) { View view = (infate/build your view) // Do stuff here RootView.addView(view); }