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.

It seems like an Id not likely to clash with an XML @id value in
R.java would be better.

Is there a "best practice" pattern for generating View Id's at
runtime?

On May 20, 11:27 am, jotobjects <[email protected]> wrote:
> Adding more detail to question - the source for CompoundButton shows
> that findViewById() is used to find the currently checked button.  So
> that means ID's I assign to these buttons must be unique in the
> current View hierarchy.
>
> Does anyone have a suggestion on generating unique View ID''s at
> runtime?
>
> On May 20, 11:07 am, jotobjects <[email protected]> wrote:
>
>
>
> > I am generating RadioButtons in code and adding them to a RadioGroup.
> > Seems like I need ID values to be able to use check(id) and so forth.
> > The bug I have now is that calling RadioButton.setChecked(true) does
> > not uncheck the already checked button.
>
> > For creating ID's in code can I just use  1,2,3,... id values or
> > whatever for the RadioButtons to work correctly with check(id)?

-- 
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

Reply via email to