java - Android How Get Option Menu ItemId, that add "menu" Dynamacally ? Explain Below -
java - Android How Get Option Menu ItemId, that add "menu" Dynamacally ? Explain Below -
there complexity ......how can resolve
i add together alternative menu dynamacally
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.main, menu); menu.clear(); (int = 0; < splashactivity.arraylistssports.size(); i++) { lists.add(splashactivity.arraylistssports.get(i)); arrylist.add(splashactivity.arraylistssportsurl.get(i)); menu.add(i, i, i, splashactivity.arraylistssports.get(i)); // menu.add(groupid, itemid, order, title) } homecoming super.oncreateoptionsmenu(menu); }
how can onoptionsitemselected(menuitem item)
itemid
mean id on "itemselected" , perform operation
basically add together or parse info form xml , save required info oncreateoptionsmenu(menu menu)
i want open url arrylist.add(splashactivity.arraylistssportsurl.get(i));
that added in "arraylist" -------------------------------------------------
![perfoem operation on alternative menu itemid click "itemid in order loke idexes" :)]
onoptionsitemselected(menuitem item)
how can id
@override public boolean onoptionsitemselected(menuitem item) { super.onoptionsitemselected(item); switch (item.getitemid()) { // case r.id.menu_settings: // break; } homecoming true; }
this artical useful me .... check next url (link)
http://www.yogeshblogspot.com/android-creating-option-menu-programmatically/
in case if chage xml items, mean length greater current items
then update apk version respectable xml iten lenth equal arraylist lenght equal.
or chek maximum cases
case menu_item1: break;
mean grater possiblities :)
if have idia plz share ... :-)
edited ans:
in case add
menu.add(i, i, i, splashactivity.arraylistssports.get(i)); // menu.add(groupid, itemid, order, title)
itemid in loop mean = 0, 1, 2, 3, 4, 5 .... , on
@override public boolean onoptionsitemselected(menuitem item) { super.onoptionsitemselected(item); switch (item.getitemid()) { case 0: url = splashactivity.arraylistssportsurl.get(0); getlivetvtoken(); break; case 1: url = splashactivity.arraylistssportsurl.get(1); getlivetvtoken(); break; case 2: url = splashactivity.arraylistssportsurl.get(2); getlivetvtoken(); break; case 3: url = splashactivity.arraylistssportsurl.get(3); getlivetvtoken(); break; . . . . . . . . . . . . . , on till 500 items :-) } }
java android optionmenu
Comments
Post a Comment