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

How to check which segmented control is selected? #98

Open
pinloop opened this issue May 17, 2020 · 1 comment
Open

How to check which segmented control is selected? #98

pinloop opened this issue May 17, 2020 · 1 comment

Comments

@pinloop
Copy link

pinloop commented May 17, 2020

If I create a segmented control with 3 radiobuttons?. How can I check what box is selected?

if android:id="@+id/button1" is selected = do this
if android:id="@+id/button2" is selected = do that

Tips?

@Duna
Copy link

Duna commented Aug 18, 2020

int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
if (checkedRadioButtonId == -1) {
    // No item selected
}
else{
    if (checkedRadioButtonId == R.id.radio_button1) {
        // Do something with the button
    }
}

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

2 participants