Fragment's onOptionsItemSelected doesn't get called

后端 未结 5 2018
离开以前
离开以前 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:40

    You are not chaining to the superclass in the activity methods. Please have onCreateOptionsMenu() return super.onCreateOptionsMenu(menu), and have onOptionsItemSelected() return super.onOptionsItemSelected(item) (except for the item that you are handling, which should return true to indicate that you have handled the event).

提交回复
热议问题