Android Custom Overflow Menu (no action bar and no menu)

In my application, I created my own Actionbar and it works very well.

I would like to use the behavior of overflow buttons on ICS devices without a menu button.

Is there a way to implement a custom Overflowbutton in ICS that is separate from the Actionbar?

Thank!

+5
source share
3 answers

userSeven7s basically has it with ListPopupWindow, but is even better suited in this case PopupMenu, allowing you to inflate the standard menu.xml. You can place your own Viewor Buttonin the upper right corner and in the handler onClickcreate and show PopupMenu.

ApiDemos > Views > Popup Menu. 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();
}
+19

ActionBar Sherlock? ABS , Android 2.1 . ActionBarCompat . Theme.Sherlock.ForceOverflow, .

http://actionbarsherlock.com/

QuickAction, , .

https://github.com/lorensiuswlt/NewQuickAction

0

/ , . HorizontalScrollView.

You can also take a look at the PopupWindowclass here and the ListPopupWindowdocumentation here .

0
source

All Articles