android - notifyDataSetChanged() for Adapter on custom searchview -


i have customized searchview based on this library , use following method delete suggestions:

 public synchronized void removesuggestion(string suggestion) {     if (!textutils.isempty(suggestion)) {         mcontext.getcontentresolver().delete(                 historycontract.historyentry.content_uri,                 historycontract.historyentry.table_name +                         "." +                         historycontract.historyentry.column_query +                         " = ? , " +                         historycontract.historyentry.table_name +                         "." +                         historycontract.historyentry.column_is_history +                         " = ?"                 ,                 new string[]{suggestion,string.valueof(0)}         );     }     madapter.notifydatasetchanged();  //don't works } 

it works. however, have notifydatasetchanged() adapter in order remove suggestions list right after has been deleted, did not work. ideas on this?

the adapter extends cursoradapter:

public cursorsearchadapter(context context, cursor cursor, int flags) {     super(context, cursor, 0); }  @override public view newview(context context, cursor cursor, viewgroup parent) {     return layoutinflater.from(context).inflate(r.layout.list_item, parent, false); }  @override public void bindview(view view, context context, cursor cursor) {     listviewholder vh = new listviewholder(view);     view.settag(vh);      string text = cursor.getstring(cursor.getcolumnindexorthrow(historycontract.historyentry.column_query));      boolean ishistory = cursor.getint(cursor.getcolumnindexorthrow(                                         historycontract.historyentry.column_is_history)) != 0;      vh.tv_content.settext(text);      if (ishistory) {         vh.iv_icon.setimageresource(r.drawable.ic_history_white);     }     else {         vh.iv_icon.setimageresource(r.drawable.ic_action_search_white);     } }  @override public object getitem(int position) {     string retstring = "";      // move position, query     cursor cursor = getcursor();     if(cursor.movetoposition(position)) {         retstring = cursor.getstring(cursor.getcolumnindexorthrow(historycontract.historyentry.column_query));     }      return retstring; }  private class listviewholder {     imageview iv_icon;     textview tv_content;      public listviewholder(view convertview) {         iv_icon = (imageview) convertview.findviewbyid(r.id.iv_icon);         tv_content = (textview) convertview.findviewbyid(r.id.tv_str);     } } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -