java - Show mini form with button and Edittext inside after clicking the listview -


i want show mini form button , edittext inside after clicking listview.

this code internet. how can show simple form button , textbox after long clicked in listview item.

i'm using android studio.

public class sample extends activity{      simpleadapter simpleadpt;     private edittext pass;      protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.sample);         initlist();          // listview component layout         listview lv = (listview) findviewbyid(r.id.listview);          simpleadpt = new simpleadapter(this, planetslist, android.r.layout.simple_list_item_1, new string[] {"planet"}, new int[] {android.r.id.text1});          lv.setadapter(simpleadpt);  list<map<string, string>> planetslist = new arraylist<map<string,string>>();      private void initlist() {         planetslist.add(createplanet("planet", "mercury"));         planetslist.add(createplanet("planet", "venus"));         planetslist.add(createplanet("planet", "mars"));         planetslist.add(createplanet("planet", "jupiter"));         planetslist.add(createplanet("planet", "saturn"));         planetslist.add(createplanet("planet", "uranus"));         planetslist.add(createplanet("planet", "neptune"));     }      private hashmap<string, string> createplanet(string key, string name) {         hashmap<string, string> planet = new hashmap<string, string>();         planet.put(key, name);          return planet;     } 

you might want implement itemlongclicklistener follows:

lv.setonitemlongclicklistener(new onitemlongclicklistener() {          public boolean onitemlongclick(adapterview<?> arg0, view arg1,                 int pos, long id) {             // todo auto-generated method stub              //do want do.             //if want delete entry.             lv.remove(arg2);//where arg2 position of item click             myadapter.notifydatasetchanged();              return true;         }     });  

now if want textbox , button appear alertdialog or want navigate page question.

if should popup textbox

alertdialog.builder alert = new alertdialog.builder(this);  alert.settitle("title"); alert.setmessage("message");  // set edittext view user input  final edittext input = new edittext(this); alert.setview(input);  alert.setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int whichbutton) {    // value!   } });  alert.setnegativebutton("cancel", new dialoginterface.onclicklistener() {   public void onclick(dialoginterface dialog, int whichbutton) {     // canceled.   } });  alert.show(); 

if should navigate page

intent intent = new intent(activitya.this, activityb.class); startactivity(intent); 

Comments