i've got listview made custom adapter called myadp:
public class myadp extends arrayadapter { private final string[] web; private final string[] t; public myadp(context context, int resource, int textviewresourceid, final string[] objects, string[] total) { super(context, resource, textviewresourceid, objects); this.web = objects; this.t = total; } @override public view getview(final int position, final view convertview, viewgroup parent) { final layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view row = inflater.inflate(r.layout.list_temp, parent, false); textview tv2 = (textview) row.findviewbyid(r.id.textview2); textview tv4 = (textview) row.findviewbyid(r.id.textview4); tv2.settext(web[position]); tv4.settext(string.valueof(t[position])); imagebutton del = (imagebutton) row.findviewbyid(r.id.imagebutton); del.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { }); return row; } }
and when user click on del imagebutton item deleted. tried lot, example tried delete item array(both web & t array) , re-call listview adapter wasn't successful, i've searched google , stackoverflow of codes simple listview adapter. need helps.
in custom adapter call this.notifydatasetchanged(); performing delete functionality , deleting element arraylist set adapter. have remove record arraylist have set adapter if know record can use arraylist.remove(index); , use notifydatasetchanged();
edit: go adapter , add method delete();
public void delete(int position){ data.remove(position); notifyitemremoved(position); }
in onclick(); method add this:
delete(getposition());
Comments
Post a Comment