Android RadioButton as Behavior

Hi,

I am trying to create an Android control with one choice in horizontal layout using the RadioGroup behavior. I can assign drawable just fine, but I would like to put the label of each RadioButton inside drawable, is this possible using the standard APIs?

<RadioGroup 
    android:id="@+id/switchcontainer" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:checkedButton="@+id/RadioButton02"
    android:padding="3dip">             

    <RadioButton 
        android:text="id RadioButton02" 
        android:id="@+id/RadioButton02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:button="@drawable/radio_button"
        android:paddingRight="2dip" />

    <RadioButton 
        android:text="@+id/RadioButton03" 
        android:id="@+id/RadioButton03" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:button="@drawable/radio_button"
        android:paddingRight="2dip" />> 

</RadioGroup>
+3
source share
2 answers

Ok, I found a way.

Just use @null in the attribute button and move the link to the attribute background as follows:

<RadioGroup 
    android:id="@+id/switchcontainer" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:checkedButton="@+id/RadioButton02">             

    <RadioButton 
        android:text="id RadioButton02" 
        android:id="@+id/RadioButton02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:background="@drawable/radio_button"
        android:button="@null"/>

    <RadioButton 
        android:text="@+id/RadioButton03" 
        android:id="@+id/RadioButton03" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:background="@drawable/radio_button"
        android:button="@null"/>

</RadioGroup>
+11
source

I am not sure about RadioGroup; however, this should be possible with a ListView.

Set ListView selectionMode to singleChoice.

ArrayAdapter SimpleAdapter . .

ListView, . Hello ListView

0

Source: https://habr.com/ru/post/1749616/


All Articles