How to check state Changing of Radio Button android? -


i want check if radiobutton clicked change value

here's code :

new dynamicviews().makeradiobutton(getapplicationcontext(),radiogroup,"ok"); new dynamicviews().makeradiobutton(getapplicationcontext(),radiogroup,"ok"); radiobutton radiobutton =                         new dynamicviews().makeradiobuttonforanswer(getapplicationcontext(),radiogroup,"this answer"); 

the first 2 radios created without referencing last 1 answer got reference check if checked.

here question : how can check if radiobutton ticked?

   radiobutton.setonclicklistener(new view.onclicklistener() {                     @override                     public void onclick(view v) {                         gotonextlevel = true;                     }                 }); 

this approach far not work because when users select radiobutton , after change choice value of gotonextlevel not change , set true in wrong way.

how find out long radiobutton checked set gotonextlevel true , otherwise false.

first create radiogroup if didn't yet, usual connect it's id , use setoncheckedchangelistener. can check radiobutton checked or not can have more 1 radiobutton. example:

radiogroup.setoncheckedchangelistener(new new oncheckedchangelistener(){     @override         public void oncheckedchanged(radiogroup group, int checkedid)         {             switch(checkedid)             {             case r.id.firstradiobutton:                 //implement logic                 break;             case r.id.secondradiobutton:                 //implement logic                 break;             }         }     }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -