I'm using a RadioGroup to select from a list of items. When the
activity holding the Group loads, it gets passed an item id, and calls
RadioGroup.check(id). The getCheckedRadioButtonId() returns the
correct id, but the radiobutton itself doesn't show as being selected.
If I click on any of the radiobuttons, they DO select, so it's not a
problem with isClickable or anything like that.

Here's my method, running inside of a subclass of Activity:
locGrp is the RadioGroup in the view.
locList is a corresponding list with the item names (had to use a
seperate container so they could be clickable)
currentLoc holds the integer id of the selected item

public void refreshView(){

        locGrp.removeAllViews();
        locList.removeAllViews();
        LayoutParams RGparams = new RadioGroup.LayoutParams(
                        RadioGroup.LayoutParams.WRAP_CONTENT,
                        RadioGroup.LayoutParams.WRAP_CONTENT);
        LayoutParams LLparams = new LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.WRAP_CONTENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT);
        RadioButton noneBtn = new RadioButton(this);
        TextView noneText = new TextView(this);
        noneText.setText("(none)");
        formatText(noneText);
        noneBtn.setId(NO_LOCATION);
        locGrp.addView(noneBtn, RGparams);
        locList.addView(noneText, LLparams);

        for(Entry<Integer, LocationFingerprintView> e :
LocationFingerprintRepository.getView(thisRef).entrySet()){
                RadioButton btn = new RadioButton(this);
                btn.setId(e.getKey());
                TextView text = new TextView(this);
                text.setText(e.getValue().getName());
                formatText(text);
                addListener(text, btn.getId());
                locGrp.addView(btn, RGparams);
                locList.addView(text, LLparams);
        }

        locGrp.check(currentLoc);
}

This method gets called in onCreate, onActivityResult, onResume, and
on the onCancelListener of a dialog box.

Thanks in advance,
 - TM
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to