Initiate PopupMenu inside from another PopupWindow

前端 未结 2 877
北荒
北荒 2020-12-22 12:21

Hi guys I need to initiate PopupMenu from a button that is inside another popupWindow, the problem is that when i\'m placing this button inside activity\'s root view it work

2条回答
  •  眼角桃花
    2020-12-22 12:53

    Finally i found the solution by a little trick and i'm sharing it so if someone need it. My solution isn't so great but it works without any visual difference and problem, so maybe it help in some case. I created one button in main xml file and in exact same place with the original button in PopupWindow, and in PopupMenu code I replaced v with reference for invisible button, here is my code:

    public void showSettingsPopup2(View v) {
        PopupMenu popup = new PopupMenu(getBaseContext(), findViewById(R.id.IVoptionsMenuInvis));
        popup.setOnMenuItemClickListener(this);
        popup.getMenuInflater().inflate(R.menu.main, popup.getMenu());
        popup.show();
    }
    

提交回复
热议问题