【问题标题】:RadioGroup not visible ballRadioGroup 看不到球
【发布时间】:2016-10-17 00:52:39
【问题描述】:

我的 XML 有问题。

我的 XML 没有在 textview 附近显示球。

我给你看我的代码。

提前致谢!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RadioGroup
        android:id="@+id/chk_box_tavolo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"/>

        <TextView
            android:id="@+id/name_tavolo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold" />
<!--</LinearLayout>-->
</LinearLayout>

【问题讨论】:

    标签: android xml android-layout radio-button radio-group


    【解决方案1】:

    您正在使用 Textview 作为 radioGroup 的子项,它应该是单选按钮。这是一个简洁的 android 单选按钮示例。

    http://www.mkyong.com/android/android-radio-buttons-example/

    【讨论】:

      【解决方案2】:

      如果您使用 RadioGroup,则子项必须是 RadioButton,而不是 textview 使用 RadioButton。检查this

      要创建每个单选按钮选项,请在您的 布局。但是,由于单选按钮是互斥的,您 必须在 RadioGroup 中将它们组合在一起。通过将它们分组 一起,系统确保只有一个单选按钮可以 一次选择。

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent">
      
          <RadioGroup
              android:id="@+id/chk_box_tavolo"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"/>
      
          <RadioButton
              android:id="@+id/radioMale"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="male"
              android:checked="true" />
      
      </LinearLayout>
      

      【讨论】:

        猜你喜欢
        • 2019-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-27
        • 1970-01-01
        • 2022-01-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多