21.05.2011 0:20, jotobjects пишет:
Sorry - correcting what is said above - It is RadioGroup (not CompoundButton) that uses findViewByIdea for the implementation of the checked(id) method. If I set the RadioButton id's to 1, 2, 3,... the RadioButtons work correctly.
RadioGroup calls findViewById on self, not Activity, so only its children are traversed.
It seems like an Id not likely to clash with an XML @id value in R.java would be better.
Hence, there is no possibility of an id clash with other views, not inside the radio group.
But you could just not rely on radio button IDs at all by keeping references to all of them in your code, and managing their states: pretty much all that's needed is clear the old selection when a new one is made. Look at CheckedStateTracker inside RadioGroup.java.
Is there a "best practice" pattern for generating View Id's at runtime?
AFAIK, XML-generated IDs start at 0x7f000000, and framework IDs are all above 0x800...0. That gives you a good range to work with.
-- Kostya Vasilyev -- http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

