Reputation: 1
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?
Upvotes: 0
Views: 816
Reputation:
Use the following code. If there is no text. it will return an empty string ""
((RadioButton) findViewbyId(radiobuttonId)).getText().toString()
Upvotes: 3