I have radio buttons in a radio group. I am new to java and figured out a way from stack overflow to use switch case with radio buttons.. But the problem is that where i have found the switch case code has a method show() in it for toasts...
public void onRadioButtonClicked(View view) {
//Is the button checked?
boolean checked = ((RadioButton) view).isChecked();
//Check which radio button is clicked
switch(view.getId()) {
case R.id.Omaths:
if (checked)
Toast.makeText(ChatFragment.this," O grade",Toast.LENGTH_LONG.show());
break;
}
}
Idk how to deal with that... Can anybody give me the show method... If you need reference... The XML code is below...
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="horizontal">
<RadioButton
android:id="@+id/Omaths"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="O"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="@+id/Aplusmaths"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A+"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
Any help will be really appreciated...