I have a
radioGroup with dynamically populated
radioButtons. In some cases, I must change
radioGroup’s content responding to data users selects.
radioGroup.removeAllViews(), then I add new
radioButtons. Next, I call
radioGroup.check(0) to select the first item.
The problem: after I have inserted a new set of
radioButtons, first item does not becomes selected nor programmatically (
check(0)), nor “by finger”. This occurs in case when the first item was selected in old items set. If another — not first — was selected, all works ok.
After spending some time and experimenting a lot, a have found a solution:
removeAllViews and adding new ones.
Oh… that is crazy, yes. Who can assume that removing all views does not affects some content-dependent state of radioGroup…