i’m working on custom radio button. it works fine(as it is defined in options.xml) but when i switch from options.xml to main.xml, it turns default, means it is no more highlighted. it should work like until i press it it should not turn to default.. here is radiobutton_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_down" android:state_checked="true"/>
<item android:drawable="@drawable/radio" android:state_checked="false"/>
</selector>
i’m using these in options.xml to call radio button settings.
<RadioGroup
android:id="@+id/sound"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_gravity="right"
android:layout_marginRight="0dp"
android:layout_marginTop="50dp"
android:orientation="vertical"
android:padding="0dp" >
<RadioButton
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:button="@drawable/radiobutton_selector"
android:id="@+id/on"
/>
<RadioButton
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:button="@drawable/radiobutton_selector"
android:id="@+id/off"
/>
</RadioGroup>
Please help me to figure out the issue. Thanks in advance !!!!!
You can do like this for your
RadioGroup.you need to save which radio Button you have selected ,for that you can use one variable like below.
Now whey your Activity ‘s Resume you can check one condition like below.
Get Value from SharedPrefrence Like below code;
you can use SharedPreferences by below step