简体   繁体   English

Android; 动态按钮布局

[英]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问题 [2] = 轻
question[3] = Toppings问题 [3] = 浇头

value[2] = on / off值[2] = 开/关
value[3] = cheese / peppers / oranges / apples值[3] = 奶酪/辣椒/橙子/苹果
(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:完整示例: 在此处输入图像描述

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.如果您列出的是 static 并且您考虑使用简单布局创建相同的方式,使用textview作为问题和buttons作为值。

Or要么

You can use the recyclerview with GridLayoutManager ans set the column count dynamically as shown here .您可以将recyclerviewGridLayoutManager一起使用并动态设置列数,如此处所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM