Radio button in android studio | Sololearn: Learn to code for FREE!


Radio button in android studio

I have created 5 radio buttons and trying to display the total number of radio buttons I have selected but the app is getting crash. I may be due to use of count++ because if I don't use count++ and just display a toast it is working fine.

1/20/2019 9:31:52 PM


5 Answers

New Answer


You must have a reference to radiobuttons before using them... Something like: RadioButton r1 = findViewById(<id of radiobutton 1>);


Hi! Probably you want to put your RadioButtons inside a RadioGroup... look at this document: Look at slides 13..15 (In spanish... sorry :) ) - or you must add a listener for every radiobutton... ...hope that helps.. :)


Yes I have already created all of them. That's what I am saying, in the If statement if I try to print a Toast it is working but if I try to do an arithmetic operation like count++ the app gets crashing.


hussein [OFFLINE] can you please look at this


Thanks, I have assigned a listener for every radio button and my problem is solved.