android - How to create a clickable Listview and go to new page where the user can add items within the list -


i guidance on how create clickable listview , go new page user can add items within list creating list, , want user able create multiple lists, , tap list, , enter multiple items within list.

thanks.

update - added .java code reference. may explain have implemented far better text above.

public class actionbarmenudemoactivity extends sherlocklistactivity { private static final string[] items = {  }; private arraylist<string> words = null;   @override public void oncreate(bundle icicle) {     super.oncreate(icicle);     initadapter();     registerforcontextmenu(getlistview()); }  @override public boolean oncreateoptionsmenu(menu menu) {     new menuinflater(this).inflate(r.menu.option, menu);      edittext add = null;      if (build.version.sdk_int >= build.version_codes.honeycomb) {         view v = menu.finditem(r.id.add).getactionview();          if (v != null) {             add = (edittext) v.findviewbyid(r.id.title);         }     }      if (add != null) {         add.setoneditoractionlistener(onsearch);     }      return (super.oncreateoptionsmenu(menu)); }  public void oncreatecontextmenu(menu menu, view v,         contextmenu.contextmenuinfo menuinfo) {     new menuinflater(this).inflate(r.menu.context, menu); }  @override public boolean onoptionsitemselected(menuitem item) {      switch(item.getitemid())     {     case r.id.add:         add();         break;     case r.id.preferences:         startactivity(new intent(getapplicationcontext(),settingsactivity.class));         break;     }      return (super.onoptionsitemselected(item)); }   @override @suppresswarnings("unchecked") public boolean oncontextitemselected(android.view.menuitem item) {     adapterview.adaptercontextmenuinfo info = (adapterview.adaptercontextmenuinfo) item.getmenuinfo();     arrayadapter<string> adapter = (arrayadapter<string>) getlistadapter();      int itemid = item.getitemid();     if (itemid == r.id.cap) {         string input = words.get(info.position);         input = input.touppercase();         adapter.remove(words.get(info.position));         adapter.insert(input, info.position);         return (true);     }      return (super.oncontextitemselected(item)); }  private void initadapter() {     words = new arraylist<string>();      (string s : items) {         words.add(s);     }      setlistadapter(new arrayadapter<string>(this,             android.r.layout.simple_list_item_1, words)); }  private void add() {     final view addview = getlayoutinflater().inflate(r.layout.add, null);      new alertdialog.builder(this).settitle("add list").setview(addview)             .setpositivebutton("create", new dialoginterface.onclicklistener() {                 public void onclick(dialoginterface dialog, int whichbutton) {                     addword((textview) addview.findviewbyid(r.id.title));                 }             }).setnegativebutton("cancel", null).show(); }  @suppresswarnings("unchecked") private void addword(textview title) {     arrayadapter<string> adapter = (arrayadapter<string>) getlistadapter();      adapter.add(title.gettext().tostring());     toast.maketext(actionbarmenudemoactivity.this,             title.gettext().tostring() + " created", toast.length_long)             .show();      title.settext(""); }  private textview.oneditoractionlistener onsearch = new textview.oneditoractionlistener() {     public boolean oneditoraction(textview v, int actionid, keyevent event) {         if (event == null || event.getaction() == keyevent.action_up) {             addword(v);              inputmethodmanager imm = (inputmethodmanager) getsystemservice(input_method_service);              imm.hidesoftinputfromwindow(v.getwindowtoken(), 0);         }          return (true);     } };       } 

some of code removed, used tutorial starting point.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -