【问题标题】:How do I add an EditText to a RadioButton?如何将 EditText 添加到 RadioButton?
【发布时间】:2021-01-06 11:22:14
【问题描述】:

我希望人们能够通过带有单选按钮的对话框从应用程序内部更改他们的状态,以便他们可以从“在线”、“离开”、“请勿打扰”和“离线”进行更改。我希望人们能够使用 EditText 单选按钮添加自定义状态。

这是我目前所拥有的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp">

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RadioButton android:id="@+id/rbOnline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/online"/>

        <RadioButton android:id="@+id/rbAway"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/away"/>

        <RadioButton android:id="@+id/rbDnd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/dnd"/>

        <RadioButton android:id="@+id/rbOffline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/offline"/>

        <RadioButton android:id="@+id/rbCustom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

    </RadioGroup>

    
</RelativeLayout>

最后一个,rbCustom 是应该有一个编辑文本的单选按钮。我应该怎么做才能做到这一点?

【问题讨论】:

  • RadioButton被选中时,您可以尝试显示EditText

标签: android android-edittext radio-button android-relativelayout radio-group


【解决方案1】:

我遇到了类似的问题,并从中得到了解决方案。答案在这里https://stackoverflow.com/a/11014041/10974012

【讨论】:

  • 抱歉,我在问是否可以向该单选按钮添加编辑文本而不是默认文本。
猜你喜欢
  • 2017-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-11
相关资源
最近更新 更多