Reputation: 61
I have done a action menu bar using action bar sherlock library. How i can add sub menus on each menu. When clicking a menu it will open a list of menus.
here is my code
// First Menu Button
menu.add("Help").setOnMenuItemClickListener(this.HelpButtonClickListener)
.setIcon(R.drawable.help_button)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
// Second Menu Button
menu.add("Like").setOnMenuItemClickListener(this.LikeButtonClickListener)
.setIcon(R.drawable.like_button)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
// Third Menu Button
menu.add("Exit").setOnMenuItemClickListener(this.ExitButtonClickListener)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
// Fourth Menu Button
menu.add("Tab1").setOnMenuItemClickListener(this.Tab1ButtonClickListener)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
Upvotes: 1
Views: 2145
Reputation: 3155
The addSubMenu method returns a SubMenu object. A SubMenu is also a Menu, so you can call add on it to add items to the submenu rather than the parent menu. Your code above is creating two different submenus for Form 1 and Form 2 rather than two items within a single New Form submenu.
Find full details in this thread: How to add submenu items to ActionBar action in code?
Upvotes: 1