java - ExpandableListAdapter with searchView only Group -


i preparing app our city people find want fast , offline. using expandablelistadapter searchview , need make group items searchable.is possible please ? ...

here´s code:

mainactivity.java

package com.martin.icmt;  import java.util.arraylist; import java.util.hashmap; import java.util.list;  import android.app.activity; import android.os.bundle; import android.widget.expandablelistview; import android.widget.searchview;  import com.martin.icmt.com.martin.icmt.expandablelist.expandablelistadapter;  public class mainactivity extends activity {     expandablelistadapter listadapter;     expandablelistview explistview;     searchview search;     list<string> listdataheader;     hashmap<string, list<string>> listdatachild;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          // listview         explistview = (expandablelistview) findviewbyid(r.id.lvexp);          // preparing list data         preparelistdata();          listadapter = new expandablelistadapter(this, listdataheader, listdatachild);          // setting list adapter         explistview.setadapter(listadapter);     }      /*      * preparing list data      */     private void preparelistdata() {         listdataheader = new arraylist<string>();         listdatachild = new hashmap<string, list<string>>();          // adding child data         listdataheader.add("nemocnica");         listdataheader.add("akb martinská kaliareň");         listdataheader.add("tesco informačné centrum");         listdataheader.add("pizzeria venezia");         listdataheader.add("pizzeria milano");         listdataheader.add("oc tulip");          // adding child data         list<string> nemocnica = new arraylist<string>();         nemocnica.add("otváracie hodiny:                                            nonstop");         nemocnica.add("telefón"+"                   0432 545 684");          list<string> akb = new arraylist<string>();         akb.add("otváracie hodiny:                                    06:00-18:00");         akb.add("telefón"+"                 0524 456 545");          list<string> tescoic = new arraylist<string>();         tescoic.add("otváracie hodiny:                                            nonstop");         tescoic.add("telefón"+"                 043 / 421 81 11");          list<string> venezia = new arraylist<string>();         venezia.add("otváracie hodiny:                                    06:00-18:00");         venezia.add("telefón"+"                 043 / 430 4916");          list<string> milano = new arraylist<string>();         milano.add("otváracie hodiny:                                    08:00-22:00");         milano.add("telefón"+"                 0907 391 404");          list<string> tulip = new arraylist<string>();         tulip.add("otváracie hodiny:                                    09:00-21:00");         tulip.add("telefón" + "               043 / 424 15 00");          listdatachild.put(listdataheader.get(0), nemocnica); // header, child data         listdatachild.put(listdataheader.get(1), akb);         listdatachild.put(listdataheader.get(2), tescoic);         listdatachild.put(listdataheader.get(3), venezia);         listdatachild.put(listdataheader.get(4), milano);         listdatachild.put(listdataheader.get(5), tulip);     } } 

expandablelistadapter.java

package com.martin.icmt.com.martin.icmt.expandablelist;  import java.util.hashmap; import java.util.list;  import android.content.context; import android.graphics.typeface; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.baseexpandablelistadapter; import android.widget.filter; import android.widget.textview;  import com.martin.icmt.r;  public class expandablelistadapter extends baseexpandablelistadapter {      private context _context;     private list<string> _listdataheader; // header titles     // child data in format of header title, child title     private hashmap<string, list<string>> _listdatachild;      public expandablelistadapter(context context, list<string> listdataheader,                                  hashmap<string, list<string>> listchilddata) {         this._context = context;         this._listdataheader = listdataheader;         this._listdatachild = listchilddata;     }      @override     public object getchild(int groupposition, int childposititon) {         return this._listdatachild.get(this._listdataheader.get(groupposition))                 .get(childposititon);     }      @override     public long getchildid(int groupposition, int childposition) {         return childposition;     }      @override     public view getchildview(int groupposition, final int childposition,                              boolean islastchild, view convertview, viewgroup parent) {          final string childtext = (string) getchild(groupposition, childposition);          if (convertview == null) {             layoutinflater infalinflater = (layoutinflater) this._context                     .getsystemservice(context.layout_inflater_service);             convertview = infalinflater.inflate(r.layout.list_item, null);         }          textview txtlistchild = (textview) convertview                 .findviewbyid(r.id.lbllistitem);          txtlistchild.settext(childtext);         return convertview;     }      @override     public int getchildrencount(int groupposition) {         return this._listdatachild.get(this._listdataheader.get(groupposition))                 .size();     }      @override     public object getgroup(int groupposition) {         return this._listdataheader.get(groupposition);     }      @override     public int getgroupcount() {         return this._listdataheader.size();     }      @override     public long getgroupid(int groupposition) {         return groupposition;     }      @override     public view getgroupview(int groupposition, boolean isexpanded,                              view convertview, viewgroup parent) {         string headertitle = (string) getgroup(groupposition);         if (convertview == null) {             layoutinflater infalinflater = (layoutinflater) this._context                     .getsystemservice(context.layout_inflater_service);             convertview = infalinflater.inflate(r.layout.list_group, null);         }          textview lbllistheader = (textview) convertview                 .findviewbyid(r.id.lbllistheader);         lbllistheader.settypeface(null, typeface.bold);         lbllistheader.settext(headertitle);          return convertview;     }      @override     public boolean hasstableids() {         return false;     }      @override     public boolean ischildselectable(int groupposition, int childposition) {         return true;     } } 


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -