gpt4 book ai didi

android - 如何从屏幕底部获取弹出菜单?

转载 作者:行者123 更新时间:2023-11-30 02:49:45 25 4
gpt4 key购买 nike

我正在处理我的联系人列表,因为我需要一个弹出菜单来获取联系人我在以下代码的帮助下获得了弹出菜单和选项:

 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
}

但我的问题是弹出窗口出现在按钮下方,我需要的是让弹出窗口出现在屏幕底部是否有可能获得它。

如果对此有任何想法,请帮助我的 friend 。

最佳答案

据我所知,您不能为此目的使用 PopupMenu。

正如文档所说:

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.

您可能想尝试使用 PopupWindow,它允许这样的定位。

关于android - 如何从屏幕底部获取弹出菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24410280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com