0

So I'm writing an app that requires me to have a radio group, and when a certain radio button is clicked in that group, points get added to the total.

So far, I have

int radiobuttonid = rg.getCheckedRadioButtonId();
rb = (RadioButton) findViewbyId(radiobuttonId);

This is to get what radio button is pressed, but I have no idea how to get a string/text from the button to form my if-else statements. Any ideas?

  • The answer is already in another post... Link : https://stackoverflow.com/questions/11194515/android-get-value-of-the-selected-radio-button – Nico Demo Oct 09 '17 at 22:08
  • Possible duplicate of [Android get value of the selected radio button](https://stackoverflow.com/questions/11194515/android-get-value-of-the-selected-radio-button) – Rapunzel Van Winkle Oct 09 '17 at 22:20

1 Answers1

3

Use the following code. If there is no text. it will return an empty string ""

((RadioButton) findViewbyId(radiobuttonId)).getText().toString()