【问题标题】:List of independent RadioGroups独立 RadioGroup 列表
【发布时间】:2014-12-27 21:26:49
【问题描述】:

我到处都在寻找解决我的问题的方法,但我的问题有点具体......我需要一个关于如何创建独立无线电组列表的建议,例如:

o item1 • item1'

• item2 o item2'

o item3 • item3'

我会将这些无线电组存储在哪种对象中,以及如何生成它们。单选按钮也会动态生成。我是使用 listview 还是不需要它?请帮忙。

【问题讨论】:

    标签: android list listview radio-group


    【解决方案1】:

    我认为您应该考虑使用垂直线性布局,然后将 radiogroups 放置为子元素,就像这样

            <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
    
            <RadioGroup
                android:id="@+id/radioGroup1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <RadioButton
                    android:id="@+id/radio0"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="true"
                    android:text="RadioButton" />
    
                <RadioButton
                    android:id="@+id/radio1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="RadioButton" />
            </RadioGroup>
    
            <RadioGroup
                android:id="@+id/radioGroup2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <RadioButton
                    android:id="@+id/radio3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="true"
                    android:text="RadioButton" />
    
                <RadioButton
                    android:id="@+id/radio4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="RadioButton" />
            </RadioGroup>
        </LinearLayout>
    

    您最终会得到您所描述的布局。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 2021-01-21
      • 2016-06-28
      • 1970-01-01
      相关资源
      最近更新 更多