java - All textView are modify in Custom ListAdapter after AlertDialog -
i fill arraylist <'hashmap <'string, string>> asynctask , set adapter custom adapter , , creat each view in getview()
. until here , works. pet listener on linear_layout
open alertdialog edittextfield. , when want change textview after have clicked , textview change , when scrool , come , start value (that in asynctask) appear. it's if value not save @ position.
this getview() method :
@override public view getview(int position, view convertview, viewgroup parent) { if (convertview == null) { holder = new customlistingcrossholder(); convertview = m_inflater.inflate(r.layout.list_type_tournee, null); holder.miscellaneous = (textview) convertview.findviewbyid(r.id.miscellaneous); holder.infos = (textview) convertview.findviewbyid(r.id.infos); holder.linear_divers = (linearlayout) convertview.findviewbyid(r.id.test); convertview.settag(holder); } else { holder = (customlistingcrossholder) convertview.gettag(); } holder.miscellaneous.settext(this.listitem.get(position).get("miscellaneous")); holder.infos.settext(this.listitem.get(position).get("infos")); holder.linear_divers.setonclicklistener(new view.onclicklistener() { view alertdialogview = m_inflater.inflate(r.layout.alert_dialog_divers, null); public void onclick(view v) { customlistingcrossholder cmh = (customlistingcrossholder) v.gettag(); alertdialog.builder adb = new alertdialog.builder(ctx); final edittext input = new edittext(ctx); adb.setview(input); adb.setpositivebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int whichbutton) { diver_edit = input.gettext().tostring(); holder.miscellaneous.settext(diver_edit); // it's here change textview } }); adb.setnegativebutton("cancel", null); adb.create().show(); } }); return convertview; }
and holder class :
private class customlistingcrossholder { textview infos; textview miscellaneous; linearlayout linear_divers; }
so can't "save" value of textfield
of alertdialog
position , don't change when scroll.may know correct way achieve objective?
edit 1 : call listview in onpostexecute of asynctask code set adapter :
@override protected void onpostexecute(string result) { super.onpostexecute(result); this.pdialog.dismiss(); log.i("asynctasklistcrossingpoint", "onpostexecute"); jsonarray jarray = new jsonarray(); jsonobject json_data = null; hashmap<string, string> map; arraylist<hashmap<string, string>> listitem = new arraylist<hashmap<string, string>>(); if (!result.startswith("error", 2)) { // recuperation des donnees json try { jarray = new jsonarray(result); } catch (jsonexception e) { log.i("tagjsonexp", "" + e.tostring()); } catch (parseexception e) { log.i("tagjsonpars", "" + e.tostring()); } log.i("jarray", jarray.tostring()); // insertion des données json dans un hashmap (int = 0; < jarray.length(); i++) { try { json_data = jarray.getjsonobject(i); map = new hashmap<string, string>(); map.put("miscellaneous",json_data.getstring("miscellaneous") != "null" ? json_data.getstring("miscellaneous") : "aucune"); map.put("infos",json_data.getstring("infos") != "null" ? json_data.getstring("infos") : "aucune"); listitem.add(map); } catch (jsonexception e) { // todo auto-generated catch block e.printstacktrace(); } } this.adapter = new customlistingcrossadapter(this.mycontext, listitem); listview.setadapter(this.adapter); } }
and code @ top of post getview method in customlistingcrossadapter
i resolved problem. put
final hashmap<string, string> object = (hashmap<string, string>) this.getitem(position);
to item @ position of click , put new value same name key in hashmap :
holder.linear_divers.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { alertdialog.builder adb = new alertdialog.builder(ctx); final edittext input = new edittext(ctx); adb.setview(input); adb.setpositivebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int whichbutton) { diver_edit = input.gettext().tostring(); object.put("miscellaneous", diver_edit); //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ log.i("objet", "o : " + object.get("miscellaneous")); } }); adb.setnegativebutton("cancel", null); adb.create().show(); } });
Comments
Post a Comment