Fragment's onOptionsItemSelected doesn't get called

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

    If your Activity's onOptionsItemSelected method returs true, the call is consumed in activity and Fragment's onOptionsItemSelected is not called. So, return false in your Activity onOptionsItemSelected method or parent class implementation via super.onOptionsItemSelected call (default implementation returns false).

    According Activity class javadoc, method Activity.onOptionsItemSelected should:

    Return false to allow normal menu processing to proceed, true to consume it here

提交回复
热议问题