So I have a radio group with 2 radio buttons, when user select the first one it's going to display a text under the radio group, if user selects the second one it's going to display different message on the same area. It's really easy to do this with Toast but I don't want to do it with Toast message.
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Button rb1 = (Button) getActivity().findViewById(R.id.radioButton1);
Button rb2 = (Button) getActivity().findViewById(R.id.radioButton2);
rb1.setOnClickListener(next_Listener);
rb2.setOnClickListener(next_Listener);
}
private OnClickListener next_Listener = new OnClickListener() {
public void onClick(View v) {
RadioGroup radio_grp=(RadioGroup)getActivity().findViewById(R.id.radio_grp);
RadioButton rb1=(RadioButton)getActivity().findViewById(R.id.radioButton1);
RadioButton rb2=(RadioButton)getActivity().findViewById(R.id.radioButton1);
if(rb1.isChecked() == true) {
// display text if they click 1st button
}
if (rb2.isChecked()) == true {
// display text if they click 2nd button
}
}
}