(https://i.stack.imgur.com/HydEx.png)
hey guys, i have problem with switch case in android studio in this case i have a radio group "radioGroup_newAc_n1" and 3 radio button "radioButton_newAc_rb1,rb2,rb3" and i wrote this code, but i got this error in the compilation process... whats wrong? you can see deatails in pic...
RadioGroup rgOptions = findViewById(R.id.radioGroup_newAc_n1);
rgOptions.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.radioButton_newAc_rb1: // <--Line72
Toast.makeText(NewAc.this,"rb1 is checked",Toast.LENGTH_SHORT).show();
break;
case R.id.radioButton_newAc_rb2: // <--Line75
Toast.makeText(NewAc.this,"rb2 is checked",Toast.LENGTH_SHORT).show();
break;
case R.id.radioButton_newAc_rb3: // <--Line78
Toast.makeText(NewAc.this,"rb3 is checked",Toast.LENGTH_SHORT).show();
break;
}
}
});
Error:
NewAc.java:72: error: constant expression required
case R.id.radioButton_newAc_rb1:
^
NewAc.java:75: error: constant expression required
case R.id.radioButton_newAc_rb2:
^
NewAc.java:78: error: constant expression required
case R.id.radioButton_newAc_rb3:
^
this is my first question in stackoverflow and actually don't have idea what's need to be here :D