How to maintain a radiobutton marking when scrolling a listview?

Asked

Viewed 67 times

0

Good afternoon, I have an edited listview and inside it I own a radioGroup. I need that when scrolling the listview, the marking on the radioGroup does not lose its marking.

Follows the xml.

 <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

        <RadioButton
            android:id="@+id/sim"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Sim"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            />

        <RadioButton
            android:id="@+id/nao"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Não"
            android:layout_below="@+id/questao"
            android:layout_toEndOf="@+id/sim"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            />

        <RadioButton
            android:id="@+id/na"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="NA"
            android:layout_below="@+id/questao"
            android:layout_toEndOf="@+id/nao"
            />
            </RadioGroup>
  • 3

    Your Listview uses an Adapter which in turn accesses an Array (probably of objects) where each Listview item must be associated with an instance of that object at a certain array position. What you have to do is to save the status of each radio as a variable in the object and, whenever you change the status, you have to update the corresponding object and then notify the Adapter that there have been changes in it.

  • Post your code as I have never seen this behavior on a listviewm may be something in your implementation that is not keeping the radiobutton in its state

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.