onPrepareOptionsMenu not getting called in Fragments

后端 未结 4 1294
花落未央
花落未央 2021-01-07 17:34
    @Override
    public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
        Log.d(\"Does\", \"get called\");
        inflater.inflate(R.menu.menuItem         


        
4条回答
  •  死守一世寂寞
    2021-01-07 18:30

    On Android 3.0 and higher, the options menu is considered to always be open when menu items are presented in the action bar. When an event occurs and you want to perform a menu update, you must call invalidateOptionsMenu() to request that the system call onPrepareOptionsMenu().

    http://developer.android.com/guide/topics/ui/menus.html

    To change particular item use: menu.findItem(R.id.your_item_id)

提交回复
热议问题