Android; 动态按钮布局

huangapple go评论89阅读模式
英文:

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)
(我将这些值按" / "分隔)

现在我想在列表中使用按钮代替值,对于列表中的每个问题和值,是否有可能,如果是,创建这样的布局的最佳方法是什么?

完整示例: Android; 动态按钮布局

英文:

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?

full example: Android; 动态按钮布局

答案1

得分: 1

如果您的列表是静态且较小的话,您可以考虑使用简单的布局,使用 textview 来显示问题,使用 buttons 来显示值。

或者

您可以使用 recyclerviewGridLayoutManager,并根据需要动态设置列数,如此处所示:链接

英文:

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 .

huangapple
  • 本文由 发表于 2020年7月29日 15:28:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63148447.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定