> The code you posted adds 10 RBs to a group. Then your get function returns a
> new one that's not associated with anything.
hu ? the only radio button I add are the one returned from the
function :
group.addView(getRadioButton(i));
it is equivalent to the following code (which doesn't work either) :
for (int i = 0; i < 10; i++) {
RadioButton v = new RadioButton(this);
if (i == 3) {
v.setChecked(true);
}
group.addView(v);
}
On Sep 15, 3:42 pm, TreKing <[email protected]> wrote:
> On Wed, Sep 15, 2010 at 8:35 AM, Christophe <
>
> [email protected]> wrote:
> > > 1 - Your getRadioButton function returns a new RadioButton.
>
> > since I want 10 different radio buttons in my group, I can reuse the
> > same radio button ?!?
>
> The code you posted adds 10 RBs to a group. Then your get function returns a
> new one that's not associated with anything. How do you expect that to work?
> You're basically saying, "when getting a Radio Button, instead of getting
> one I already created, make a new one and if was trying to get the first
> one, set it to checked. Also, don't associate it with a group so its checked
> state won't effect others."
>
> > > 2 - You're using getApplicationContext().
>
> > I have try with just "this" instead of "getApplicationContext()", but the
> > problem is still there
>
> This won't fix your problem (see #1), but you should avoid
> getApplicationContext(). It will cause you problems elsewhere.
>
> Should I use something else ?
>
> Your most local Context ... usually "this".
>
> On Wed, Sep 15, 2010 at 8:38 AM, Kumar Bibek <[email protected]> wrote:
> > 1. New Radio button: I dont see a problem with that.
>
> He already created 10 and the "new" ones don't get added to the group.
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
--
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