-1
I created a RadioGroup
with 3 RadioButton
internal, however I cannot fit a code that makes the user when selecting a RadioButton
is prevented from selecting another.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="O que você coloca em uma torradeira?"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textColor="@android:color/black"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rgRespostas">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rbResposta1"
android:text="Torrada"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rbResposta2"
android:text="Bolo"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rbResposta3"
android:text="Pão"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"/>
</RadioGroup>
</LinearLayout>
And how do I do that? Type, I create a method in Activity and link to the Radiogroup id and create the following condition: If user click on rbResposta1, then disable the rbResposta2 and rbResposta3 option. Something like that?
– Carlos Rauta
It would be easier to disable Radiogroup.
– ramaral
Voce can use the Oncheckedchangelistener method and inside put public void onCheckedChanged(compoundbutton compoundButton, Boolean b) { rbResposta2.setEnabled(false);
– Igor Nobre