Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I implemented Radio buttons inside preference activity that looks like check boxes as follows..</p> <p><img src="https://i.stack.imgur.com/vU53w.png" alt="enter image description here"></p> <p>Only one can be selected at a time. I done this using 2 more xml files</p> <p><img src="https://i.stack.imgur.com/mrZgW.png" alt="enter image description here"></p> <p>One inside drawable(check_dyn.xml) and another inside layout(radiochecks.xml) .</p> <p><strong>check_dyn.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_checked="false" android:state_enabled="true" android:drawable="@android:drawable/checkbox_off_background" /&gt; &lt;item android:state_checked="true" android:state_enabled="true" android:drawable="@android:drawable/checkbox_on_background" /&gt; &lt;/selector&gt; </code></pre> <p><strong>radiochecks.xml</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;RadioButton android:id="@+id/radio0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/check_dyn" android:checked="true" android:text="RadioButton1" /&gt; &lt;RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/check_dyn" android:text="RadioButton2" /&gt; &lt;RadioButton android:id="@+id/radio2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/check_dyn" android:text="RadioButton3" /&gt; &lt;/RadioGroup&gt; &lt;/LinearLayout&gt; </code></pre> <p>Now, inside the preference,(here prefs.xml), add a preference and set its layout property. ie,</p> <pre><code>&lt;Preference android:layout="@layout/radiochecks" /&gt; </code></pre> <p>Note: I don't prefer a practice like this, since it is hard to get the individual values.</p> <p>I prefer -></p> <p><img src="https://i.stack.imgur.com/e3Pz0.png" alt="From settings"> <img src="https://i.stack.imgur.com/csjnW.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload