android - get checkbox checked on first click -
i creating checkboxes dynamically. want check 1 checkbox @ time.i have achieved using setchecked(false) method.its working fine,the problem when unchecked first checkbox , click on sec 1 getting checked @ sec time.i want checked @ first time.
code have used-
cb.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview,boolean ischecked) { log.e("ischecked",""+ischecked); if(ischecked==true) { count++; senddata(j); if(count>1) { //cb[i].setchecked(false); buttonview.setchecked(false); count=0; } } };
@neha seek this...
@override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if(ischecked) { if(count==0) { count++; toast.maketext(mainactivity.this, "count="+count, 0).show(); return; } buttonview.setchecked(false); } else { count--; toast.maketext(mainactivity.this, "count="+count, 0).show(); return; } }
android checkbox
No comments:
Post a Comment