Android: How to make RadioGroup work correctly in a ListView?

后端 未结 1 898
轻奢々
轻奢々 2020-12-06 03:40

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 ListVi

相关标签:
1条回答
  • 2020-12-06 04:26

    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.

    0 讨论(0)
提交回复
热议问题