Android custom Overflow-menu (Without actionbar and no menubutton)

android, android-actionbar

Solution

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();
}

Problem

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!

Original source