【问题标题】:Create radio group using array adapter使用阵列适配器创建无线电组
【发布时间】:2013-12-27 12:55:57
【问题描述】:

我想使用数组适配器创建一组单选按钮。我想获取其中一个被选中的信息并取消选择任何按钮的其他按钮。谁能帮我这样做

【问题讨论】:

  • 您是否尝试将单选按钮放入 ListView 中?
  • 请贴一些代码..你做了什么?
  • 不,我正在尝试使用数组适配器在线性布局中一一添加单选按钮。我将单选按钮作为视图,然后将其添加到我的线性布局中。

标签: android radio-button radio-group


【解决方案1】:

请尝试以下方法:

     <RadioGroup
            android:id="@+id/radio"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2"
            android:orientation="horizontal" >

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:gravity="center"
                android:text="Free Lancer"
                android:textSize="15dp" />

            <RadioButton
                android:id="@+id/radioButton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:gravity="center"
                android:text="Firm/companies"
                android:textSize="15dp" />
        </RadioGroup>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-16
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多