Android custom filter/search Gridview -
i'm using custom adapter search in gridview
has images , texts. problem if update server new pictures , texts, texts updated. how can update images well?
here custom filter
class customfilter extends filter { @override protected filterresults performfiltering(charsequence constraint) { filterresults results = new filterresults(); if(constraint != null && constraint.length()>0) { // constraint upper constraint = constraint.tostring().touppercase(); arraylist<bookdata> filters = new arraylist<bookdata>(); //get specific items for(int i=0;i<filterlist.size();i++){ if(filterlist.get(i).getname().touppercase().contains(constraint)){ bookdata p= new bookdata(filterlist.get(i).getid(),filterlist.get(i).getname(),filterlist.get(i).getpath_1(),filterlist.get(i).getpath_2(),filterlist.get(i).getbooklocalpath(),filterlist.get(i).getimagepath_1(),filterlist.get(i).getimagepath_2(),filterlist.get(i).getimagelocalpath()); filters.add(p); } } results.count= filters.size(); results.values=filters; }else{ results.values = filterlist; results.count = filterlist.size(); } return results; } @override protected void publishresults(charsequence constraint, filterresults results) { arraylist = (arraylist<bookdata>) results.values; notifydatasetchanged(); } }
im using following method in activity class
gridview = (gridview) findviewbyid(r.id.gridview_a3lam); sv = (searchview) findviewbyid(r.id.sv); gridview.setonitemclicklistener(this); sv.setonquerytextlistener(new searchview.onquerytextlistener() { @override public boolean onquerytextsubmit(string query) { return false; } @override public boolean onquerytextchange(string query) { adapter.getfilter().filter(query); return true; } }); db = new albumdbhandler(this); }
Comments
Post a Comment