Scarlett
Scarlett

Reputation: 131

Radio Button is selected java

I'm trying to get that when a radio button within my app is selected, the application reloads. I've got the below code:

if(check.isSelected()== true){
    b1.setEnabled(true);
    finish();
    startActivity(getIntent());
}

However, the app doesn't seem to be entering the if statement even when the radio button is checked. Any ideas?

Upvotes: 1

Views: 158

Answers (2)

Mayank Bhatnagar
Mayank Bhatnagar

Reputation: 2191

Change you code as below. Use this

if(check.isChecked()== true){ 
}

instead of

if(check.isSelected()== true){ 
}

Upvotes: 0

Amsheer
Amsheer

Reputation: 7131

Try like this.

if(check.isChecked()){
    b1.setEnabled(true);
    startActivity(getIntent());
    finish();
}

You are using startActivity after finish called. Also change the if condition

Upvotes: 2

Related Questions