onPrepareOptionsMenu in Fragment not being called as of AppCompat v22 (API 10)

时间秒杀一切 提交于 2020-01-02 04:52:24

问题


We have an app that uses AppCompatActivity with multiple fragments, each of which contribute to the options menu. (i.e. the fragments override onCreateOptionsMenu and insert their own menu items)

The fragments also override onPrepareOptionsMenu, in order to conditionally enable/disable certain menu items based on the state of the app.

Prior to the updated version (22) of appcompat, the onPrepareOptionsMenu function was called for each fragment, and everything was working correctly. But now, it's no longer being called.

This behavior is only present in API 10. In newer APIs it works correctly. Any ideas?


回答1:


With a little digging, I found this: https://code.google.com/p/android/issues/detail?id=170630

Let's hope this is resolved in the next release of appcompat!



来源:https://stackoverflow.com/questions/30197508/onprepareoptionsmenu-in-fragment-not-being-called-as-of-appcompat-v22-api-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!