gpt4 book ai didi

android - 如何在 RecyclerView 项目下方显示弹出窗口?

转载 作者:行者123 更新时间:2023-12-05 02:20:36 24 4
gpt4 key购买 nike

如何在 RecyclerView 项目下方显示弹出窗口?

我应该使用PopupWindow,因为菜单是自定义布局

看图:

enter image description here

最佳答案

showPopUpMenu(View);View 传递到要附加弹出窗口的位置?

    void showPopUpMenu(View anchor) {
PopupMenu popup = new PopupMenu(MainActivity.this, anchor);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());

//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(MainActivity.this, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
}
});

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

Full Demo

关于android - 如何在 RecyclerView 项目下方显示弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38458909/

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