How to open the options menu programmatically?

前端 未结 11 1665
时光说笑
时光说笑 2020-11-28 06:47

I would like to open the optionsMenu programmatically without a click on the menu key from the user. How would I do that?

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 07:00

    For me, declaring toolbar.showOverflowMenu() in onClick is not worked. openOptionsMenu() also not worked for me. Instead of that the following way is worked for me,

    new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    toolbar.showOverflowMenu();
                }
            }, 500);
    

提交回复
热议问题