Android Custom Overflow-menu (without Actionbar And No Menubutton)
In my application I have made my own Actionbar, and it works very well. I would however like to use the behaviour of the overflow buttons on ICS-devices with no menu-button. Is the
Solution 1:
userSeven7s mostly has it with the ListPopupWindow
, but an even better fit in this case is the PopupMenu
, which allows you to inflate a standard menu.xml
. You can place your own View
or Button
in the upper right and in the onClick
handler create and show a PopupMenu.
An example can be found in ApiDemos > Views > Popup Menu . Specifically PopupMenu1.java
:
publicvoidonPopupButtonClick(View button) {
PopupMenupopup=newPopupMenu(this, button);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(newPopupMenu.OnMenuItemClickListener() {
publicbooleanonMenuItemClick(MenuItem item) {
Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
Toast.LENGTH_SHORT).show();
returntrue;
}
});
popup.show();
}
Solution 2:
Have you looked at ActionBar Sherlock? ABS provides action bar support for all devices running android 2.1 and above. The ActionBarCompat sample is very limited and does not support overflow menus on older devices. Be sure to use the Theme.Sherlock.ForceOverflow theme to enable overflow.
You could also modify the QuickAction library to do what you want.
Post a Comment for "Android Custom Overflow-menu (without Actionbar And No Menubutton)"