checkbox filter in android -


i'm trying learn more checkbox functions in android. want display values of checked checkboxes in textview. in code, shows checkboxes either true(if checked) or false (if not checked) want print checkboxes checked , exclude unchecked. tried using "if, else if" not working. appreciated.

mainactivity:

public class demo extends activity {      private checkbox linux, macos, windows;     private button button;     private edittext ed1, ed2;     private textview text;      @override     protected void oncreate(bundle savedinstancestate) {         // todo auto-generated method stub         super.oncreate(savedinstancestate);         setcontentview(r.layout.demo);         addlisteneronbutton();     }      public void addlisteneronbutton() {          linux = (checkbox) findviewbyid(r.id.checkbox1);         macos = (checkbox) findviewbyid(r.id.checkbox2);         windows = (checkbox) findviewbyid(r.id.checkbox3);         ed1 = (edittext) findviewbyid(r.id.edittext1);         ed2 = (edittext) findviewbyid(r.id.edittext2);         button = (button) findviewbyid(r.id.go);         text = (textview) findviewbyid(r.id.textview1);          button.setonclicklistener(new onclicklistener() {                @override               public void onclick(view v) {                 stringbuffer result = new stringbuffer();                 result.append("android check : ").append(linux.ischecked());                 result.append("\nwindows os check : ").append(macos.ischecked());                 result.append("\nios check :").append(windows.ischecked());                   //toast.maketext(demo.this, result.tostring(), toast.length_long).show();                 text.settext(result);               }         });     } } 

you can way :

        @override         public void onclick(view v) {              stringbuffer result = new stringbuffer();             if (linux.ischecked()) {                 result.append("android check : ").append(linux.ischecked());             }             if (macos.ischecked()) {                 result.append("android check : ").append(linux.ischecked());             }             if (windows.ischecked()) {                 result.append("\nios check :").append(windows.ischecked());             }             text.settext(result);         }     }); } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -