i'm writing application shows 2 buttons in alert dialog, 1 select objects, other show details.
i evaluate if map new items selected has values but, clearing map, condition returns false.
here code of oncreatedialog() , asynctask call dialog:
// map containing objects selected map<string, identifyresult> itemsselected = new hashmap<string, identifyresult>(); // map containing new objects selected map<string, identifyresult> longclicktemp = new hashmap<string, identifyresult>(); protected class identifyfeatures extends asynctask<identifyparameters, void, identifyresult[]> { identifytask identifier; progressdialog progress; @override protected identifyresult[] doinbackground(identifyparameters... params) { identifyresult[] result = null; if (params != null && params.length > 0) { identifyparameters usedparams = params[0]; try { result = identifier.execute(usedparams); } catch (exception e) { e.printstacktrace(); } } return result; } @override protected void onpreexecute() { identifier = new identifytask(layer2.geturl()); progress=progressdialog.show(aep41activity.this, "chargement", "récupération de la sélection"); super.onpreexecute(); } @override protected void onpostexecute(identifyresult[] result) { if (result != null && result.length > 0) { toast t = toast.maketext(aep41activity.this, result.length + " objects trouves", toast.length_short); t.show(); aep41activity.this.longclicktemp.clear(); // highlight features selected (int = 0; < result.length; i++) { // verify if object selected if (itemsselected.containskey(result[i].getattributes() .get("objectid"))) { log.d("object exists", "id: " + result[i].getattributes().get("objectid")); continue; } log.d("object found", "object type: " + result[i].getlayername() + " id: " + result[i].getattributes().get("objectid")); aep41activity.this.longclicktemp.put( (string) result[i].getattributes().get("objectid"), result[i]); } progress.dismiss(); aep41activity.this.showdialog(context_menu_select); } else { progress.dismiss(); toast t = toast.maketext(aep41activity.this, "aucun objet trouve", toast.length_short); t.show(); } } } @override protected dialog oncreatedialog(int id) { alertdialog.builder builter = new alertdialog.builder( aep41activity.this); switch (id) { case context_menu_select: builter.settitle("selectionner option"); if(!longclicktemp.isempty()){ builter.setpositivebutton("selectionner", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { itemsselected.putall(longclicktemp); updateselectedmenu(); } }); } builter.setneutralbutton("details", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { bundle b = new bundle(); b.putstringarraylist("selectedids", utilities.getstringarray(itemsselected.keyset())); b.putserializable("tabvalues", utilities .getidentifyresultarray(longclicktemp)); intent = new intent(aep41activity.this, fielddetails.class); i.putextras(b); startactivity(i); } }); break;
it problem of cached dialog.
i didn't know dialog cached in android.
to solve problem, added:
removedialog(context_menu_select);
before aep41activity.this.showdialog(context_menu_select);
Comments
Post a Comment