英文:
Android; Dynamic buttons layout
问题
I have a list filled with values and a list with questions, some elements in the value list have more than 1 element, so for example:
question[2] = 灯光 (Light)
question[3] = 配料 (Toppings)
value[2] = 开 / 关 (on / off)
value[3] = 奶酪 / 辣椒 / 橙子 / 苹果 (cheese / peppers / oranges / apples)
(我将这些值按" / "分隔)
现在我想在列表中使用按钮代替值,对于列表中的每个问题和值,是否有可能,如果是,创建这样的布局的最佳方法是什么?
英文:
I have a list filled with values and a list with questions, some elements in the value list have more than 1 element, so for example
question[2] = Light
question[3] = Toppings
value[2] = on / off
value[3] = cheese / peppers / oranges / apples
(i split these values on " / ")
now i want use buttons in place for values , for every single question and value in the lists.
is this possible and if yes what is the best approach to create such a layout?
答案1
得分: 1
如果您的列表是静态且较小的话,您可以考虑使用简单的布局,使用 textview
来显示问题,使用 buttons
来显示值。
或者
您可以使用 recyclerview
与 GridLayoutManager
,并根据需要动态设置列数,如此处所示:链接。
英文:
If you list is static and small you way consider creating same using the simple layout, using textview
for the questions and buttons
for the values.
Or
You can use the recyclerview
with GridLayoutManager
ans set the column count dynamically as shown here .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论