I want to disable the clicks on the RadioGroup placed inside the Relative Layout! In a way that my only Relative Layout should be clickable. I want this on some certain condition my XML is as follow:
<RelativeLayout
android:id="@+id/shouldNotPlayLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_marginLeft="44dp"
android:layout_marginRight="44dp"
android:layout_marginTop="40dp">
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:saveEnabled="false">
<RadioButton
android:id="@+id/radio_option_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/radio_option_selector"
android:button="@null"
android:padding="15dp"
android:textColor="#161743"
android:textSize="14sp"
android:textStyle="normal"
tools:text="First option"/>
<RadioButton
android:id="@+id/radio_option_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/radio_option_selector"
android:button="@null"
android:padding="15dp"
android:textColor="#161743"
android:textSize="14sp"
android:textStyle="normal"
tools:text="First option"/>
<RadioButton
android:id="@+id/radio_option_c"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/radio_option_selector"
android:button="@null"
android:padding="15dp"
android:textColor="#161743"
android:textSize="14sp"
android:textStyle="normal"
tools:text="First option"/>
</RadioGroup>
</RelativeLayout>
I am stopping the clicks on the radio group as:
binding.questionLayout.radioOptionA.setEnabled(false);
binding.questionLayout.radioOptionB.setEnabled(false);
binding.questionLayout.radioOptionC.setEnabled(false);
binding.questionLayout.radioOptionA.setFocusable(false);
binding.questionLayout.radioOptionB.setFocusable(false);
binding.questionLayout.radioOptionC.setFocusable(false);
binding.questionLayout.shouldNotPlayLayout.requestFocus();
binding.questionLayout.shouldNotPlayLayout.setClickable(true);
binding.questionLayout.shouldNotPlayLayout.setFocusable(true);
The Problem I am facing is that sometimes any of these three radio button can still be clickable and the user can click any radio button. But I want to disable the click on the radio group/button and get the click done on the relative layout!
Can somebody please figure any blunders done by me?