RSS

RadioGroup setOnCheckedChangeListener getting call multiple times during initialization in Android

20 Dec
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
    private boolean isChecked(RadioGroup group, int viewId) {
        if (viewId != -1) {
            View v = group.findViewById(viewId);
            if (v instanceof RadioButton) {
                return ((RadioButton) v).isChecked();
            }
        }
        return true;
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        if (!isChecked(group, checkedId)) {
            return;
        }
        // put your code here
    }
});
Advertisements
 
Leave a comment

Posted by on December 20, 2014 in Android Source Code

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: