Fragment's onOptionsItemSelected doesn't get called

后端 未结 5 1945
离开以前
离开以前 2021-02-01 03:17

My fragment replaces the parent Activity options with a specific option item but when I click on the item, only activity\'s onOptionItemSelected gets called eventho

5条回答
  •  一整个雨季
    2021-02-01 03:57

    I agree with the currently accepted solution, but another possible cause is having an ambiguous class reference. I had a custom class in my project named MenuItem and my Fragment was interpreting that custom.MenuItem as the parameter type instead of android.view.MenuItem

    The symptoms were a wiggly red underline on my Override and IDE message indicating that onOptionsItemSelected will not be called.

提交回复
热议问题