1

i am designing a layout for dialog fragment in which i have 8 RadioButton the problem is by selecting one button its changing its background but when i click on another RadioButton previous one is not going to its older state (Icon) this is my xml

 <?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Added"
            android:textColor="#000000" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="vertical">

            <RadioButton
                android:id="@+id/added_up_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"
                />

            <RadioButton
                android:id="@+id/added_down_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"


                />
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Name" />


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="vertical">


            <RadioButton
                android:id="@+id/name_up_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"
                android:textStyle="normal" />

            <RadioButton
                android:id="@+id/name_down_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"
                android:textStyle="normal" />
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="File Size" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="vertical">

            <RadioButton
                android:id="@+id/size_up_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"


                />

            <RadioButton
                android:id="@+id/size_down_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"


                />
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Created" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"

            android:orientation="vertical">

            <RadioButton
                android:id="@+id/create_up_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp" />

            <RadioButton
                android:id="@+id/create_down_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/selcetor"
                android:button="@null"
                android:padding="10dp"

                />
        </LinearLayout>


    </LinearLayout>
</RadioGroup>

and this is my selctore

 <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">

        <item android:drawable="@drawable/slected" android:state_checked="true"/>
        <item android:drawable="@drawable/unselcted"    android:state_checked="false"/>

    </selector>

enter image description here

default icon is arrow for unselected state but when i press multiple button the icon should be changes to tick but it is not changing back please guide what am i doing wrong ? or my xml is faulty

Mateen Chaudhry
  • 631
  • 12
  • 32

0 Answers0