I have a ListView, which has a TextView and a RadioGroup with 4 RadioButtons as Children in each row. Now i can select a RadioButton in each row. But if i scroll the ListView, my Selection is gone or it does not show correctly. For example, i choose the RadioButton A in the first row, if i scroll through the ListView and then go back to the first row again, either none of the RadioButtons in the RadioGroup is checked or RadioButton C is checked instead of A. How can i fix this Problem? I have tried 7 days already, but still i find no solution. Can anybody help me? I'll be very appriciate of that.
Asked
Active
Viewed 1.3k times
4
-
could you best your getView method from the adapter your using? – RoflcoptrException May 30 '10 at 09:59
-
hi tian dong i am also havin this same problem please provide me the ideas .how to prevent this selection state overide in other row of list – tamil Nov 29 '11 at 07:58
-
Can you please post here your code, i am interested for this. Thnaks. – Milos Cuculovic Dec 29 '11 at 19:11
1 Answers
8
When getView()
(or bindView()
if you are using a CursorAdapter
) is called on your adapter, you need to set the state of the RadioGroup
. Android recycles rows and is not going to track those RadioGroup
states for you.
See here for a sample project that has a RatingBar
in a row for the general technique. This is also covered in this free excerpt from one my books.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
1Unbelievable, it works! I'm soo....oo happy! And the free excerpt helps me a lot to understand how ListView of Android works. Thank you very much. I am really very appreciate of your help – TianDong May 30 '10 at 23:09