Top Picks

January 23, 2013


Android RadioGroup getCheckedRadioButtonId inconsistant


I’m using radio group with several radio buttons inside.
I implemented

RadioGroup.OnCheckedChangedListener(RadioGroup group, int checkedId)

, as well as



However, the method


always returns me one same id of my radio buttons no matter which button i click on. The listener works just fine.

I saw some posts here saying the above method works, anyone knows what’s happening? Thanks!



I was debugging and all of a sudden I realized the reason I got this bug.

When I created the radio group, I made it static, I guess the same id returned from the getCheckedRadioButtonId() is the default id. In the checkchangedlistener(RadioGroup rg, int id), rg is never the same as my static radio group. ooops

Professional Hosting fro Just Host

Filed under: Android Coding FAQ



No Comments

Leave a reply