+ 1
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. https://code.sololearn.com/c3lEqSOXMIGY/?ref=app
5 odpowiedzi
+ 2
You must have a reference to radiobuttons before using them...
Something like:
RadioButton r1 = findViewById(R.id.<id of radiobutton 1>);
+ 2
Hi! Probably you want to put your RadioButtons inside a RadioGroup... look at this document:
https://docs.google.com/presentation/d/e/2PACX-1vQQOSFfWksA_o3KAPOZQL3dDADS2emVcDIizeHwYYXGwsTkY2QIboqiFp2GU6Iy_iaoVv_K3933cSU3/pub?start=false&loop=false&delayms=10000
Look at slides 13..15 (In spanish... sorry :) )
- or you must add a listener for every radiobutton...
...hope that helps.. :)
+ 1
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.
+ 1
hussein [OFFLINE] can you please look at this
0
Thanks, I have assigned a listener for every radio button and my problem is solved.