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 there a way to implement a custom Overflowbutton in ICS that is separate from the Actionbar?
Thanks!
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
:
public void onPopupButtonClick(View button) {
PopupMenu popup = new PopupMenu(this, button);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();
}
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.
http://actionbarsherlock.com/
You could also modify the QuickAction library to do what you want.
https://github.com/lorensiuswlt/NewQuickAction
You could slide/scroll your action bar to let access to more options. Put your action bar in a HorizontalScrollView.
You might also want to take a look at PopupWindow
class here, and ListPopupWindow
documentation here.