简体   繁体   中英

How to get popup menu from bottom of screen?

I'm going on with my contacts list for that I need a popup menu should appear to get contacts I got the popup menu and options with the help of below code:

 PopupMenu popup = new PopupMenu(SettingsPage.this, dropdown);
    // Inflating the Popup using xml file
    popup.getMenuInflater().inflate(R.menu.contactmenu, popup.getMenu());

    // registering popup with OnMenuItemClickListener
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    public boolean onMenuItemClick(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.contacts:
{
// my activity
}

    default:
    return false;
    }

    }
    });

    popup.show();  */
    // showing popup menu
     }

But my problem was popup appears just below the button what I need was to get the popup in the bottom of screen is it possible to get it.

If anyidea about this please help me friends.

If i understand you cannot use a PopupMenu for this purpose.

As docs say:

A PopupMenu displays a Menu in a modal popup window anchored to a View. The popup will appear below the anchor view if there is room, or above it if there is not. If the IME is visible the popup will not overlap it until it is touched. Touching outside of the popup will dismiss it.

You may want to try to use PopupWindow perhaps, which allows such positioning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM