Initiate PopupMenu inside from another PopupWindow

前端 未结 2 871
北荒
北荒 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();
    }
    
    0 讨论(0)
  • 2020-12-22 13:04

    You can't anchor a PopupMenu to a view in a PopupWindow. You will need to anchor it to a View in a top-level window.

    0 讨论(0)
提交回复
热议问题