Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checked state change listener #95

Open
Duna opened this issue Jun 5, 2019 · 2 comments
Open

Checked state change listener #95

Duna opened this issue Jun 5, 2019 · 2 comments

Comments

@Duna
Copy link

Duna commented Jun 5, 2019

How do I set listener for state change?
setOnCheckedChangeListener seems not working.

@Morteza-Rastgoo
Copy link

same here

@buraktemzc
Copy link

Hi @Duna and @Morteza-Rastgoo.

This is a late answer but I used with RadioGroup.OnCheckedChangeListener.

`
public class MediaActivity extends BaseActivity implements, RadioGroup.OnCheckedChangeListener{

private static final String STATE_PLACE = "state_place";

@BindView(R.id.imageTypeSegmentedGroup)
SegmentedGroup imageTypeSegmentedGroup;

private Boolean placeChecked;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_media);
    ButterKnife.bind(this);

    if (savedInstanceState != null)
        placeChecked = savedInstanceState.getBoolean(STATE_PLACE, false);

    imageTypeSegmentedGroup.setOnCheckedChangeListener(this);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(STATE_PLACE, placeChecked);
    super.onSaveInstanceState(outState);
}

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (checkedId) {
        case R.id.placeRadioButton:
            placeChecked = false;
            break;
        case R.id.foodRadioButton:
            placeChecked = true;
            break;
    }
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants