java - Filtering data with checkbox , how should I do it? -


i'm trying filter data retrieve web service , i'm trying filtering of data retrieved based on category checkbox checked users. here sample of code mainactivity:

    package com.example.fambond;  import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.checkbox; import android.widget.toast;  public class mainactivity extends activity {      private class checkboxlistener implements onclicklistener {          public void onclick(view av) {             string newline = "\n";             string boxeschecked = "";             string boxinput = "";             if (a.ischecked()) {                 boxeschecked = boxeschecked + a.gettext() + newline;                 boxinput = boxinput + "education";             }             if (b.ischecked()) {                 boxeschecked = boxeschecked + b.gettext() + newline;                 boxinput =  boxinput + "," + "festivals_parades";             }             if (c.ischecked()) {                 boxeschecked = boxeschecked + c.gettext() + newline;                 boxinput = boxinput + "," + "sports";             }             if (d.ischecked()) {                 boxeschecked = boxeschecked + d.gettext() + newline;                 boxinput =  boxinput + "," + "attractions";             }             if (e.ischecked()) {                 boxeschecked = boxeschecked + e.gettext() + newline;                 boxinput =  boxinput + "," +"performing_arts";             }             if (f.ischecked()) {                 boxeschecked = boxeschecked + f.gettext() + newline;                 boxinput = boxinput + "," + "community" ;             }             if (boxeschecked.length() == 0) {                 boxeschecked = "no checkboxes checked";                      }             toast.maketext(mainactivity.this, boxinput, toast.length_short)                     .show();         }      }      private checkbox a;     private checkbox b;     private checkbox c;     private checkbox d;     private checkbox e;     private checkbox f;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         setwidgetreference();         setonclicklisteners();     }      private void setwidgetreference() {         // todo auto-generated method stub         = (checkbox) findviewbyid(r.id.checkbox1);         b = (checkbox) findviewbyid(r.id.checkbox2);         c = (checkbox) findviewbyid(r.id.checkbox3);         d = (checkbox) findviewbyid(r.id.checkbox4);         e = (checkbox) findviewbyid(r.id.checkbox5);         f = (checkbox) findviewbyid(r.id.checkbox6);     }      private void setonclicklisteners() {         // todo auto-generated method stub         checkboxlistener alistener = new checkboxlistener();         a.setonclicklistener(alistener);         b.setonclicklistener(alistener);         c.setonclicklistener(alistener);         d.setonclicklistener(alistener);         e.setonclicklistener(alistener);         f.setonclicklistener(alistener);     }  } 

this category link got webservice: http://api.evdb.com/rest/categories/list?app_key=rdkkf6nsx6ljwtdr


Comments