I need to set validation that user must fill / select all details in a page. If any fields are empty wanna show Toast message to fill. Now I need set validation
I used the id's of my radiobuttons to compare with the id of the checkedRadioButton that I got using mRadioGroup.getCheckedRadioButtonId()
Here is my code:
mRadioButton1=(RadioButton)findViewById(R.id.first);
mRadioButton2=(RadioButton)findViewById(R.id.second);
mRadioButton3=(RadioButton)findViewById(R.id.third);
mRadioButton4=(RadioButton)findViewById(R.id.fourth);
mNextButton=(Button)findViewById(R.id.next_button);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int selectedId=mRadioGroup.getCheckedRadioButtonId();
int n=0;
if(selectedId==R.id.first){n=1;}
else if(selectedId==R.id.second){n=2;}
else if(selectedId==R.id.third){n=3;}
else if(selectedId==R.id.fourth){n=4;}
//. . . .
}