Disable menu button?

后端 未结 1 1589
心在旅途
心在旅途 2021-01-12 08:23

I have a custom menu options that I want to disable it from popping up if a button on screen is clicked..

I thought of using this code but it doesnt work:



        
相关标签:
1条回答
  • 2021-01-12 08:33

    According to the documentation:

    You must return true for the menu to be displayed; if you return false it will not be shown.
    

    So I'm guessing this will work:

    @Override
     public boolean onPrepareOptionsMenu (Menu menu) {
         .... Code .....
         return !Schedule;
     }
    

    That is assuming that you want the menu to display when Schedule is equal to false.

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