I have Radiogroup and inside two radio button is there.But I cannot able to get the string value of both the radio button.
Here is my code:-
public void checkFieldsForEmptyValue(){
phonenumber=phone_number.getText().toString();
String password=Password.getText().toString();
RadioGroup radioGroup=(RadioGroup) findViewById(R.id.rg_lgoinscreen);
RadioButton radioButton_student=(RadioButton)findViewById(R.id.Radio_button_student);
RadioButton radioButton_teacher=(RadioButton)findViewById(R.id.Radio_button_teacher);
String radio_button_student=Integer.toString(radioButton_student.getId());
if(phonenumber.length() > 0 && password.length() > 0 && radio_button_student.length()>0)
{
Toast.makeText(this, "Else working", Toast.LENGTH_LONG).show();
login.setEnabled(true);
}
Here is the XML file
<RadioGroup
android:id="@+id/rg_lgoinscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_margin="1dp"
android:layout_below="@id/login_password"
android:orientation="horizontal"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/white"
android:text="Student"
android:textColor="@color/white"
android:id="@+id/Radio_button_student"
android:layout_marginLeft="19dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:buttonTint="@color/white"
android:text="Teacher"
android:textColor="@color/white"
android:id="@+id/Radio_button_teacher"/>
</RadioGroup>