menu inflating calls multiple times at fragment's onCreateOptionsMenu

前端 未结 3 572
逝去的感伤
逝去的感伤 2021-02-13 01:54

I use Fragments and when I switch to nested Fragment, which implements public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) my menu inflates quantity o

3条回答
  •  面向向阳花
    2021-02-13 02:40

    Use before replace.

     fragment = new EditMyProfile();
     FragmentTransaction fragmentTransactionEditProfile =getSupportFragmentManager().beginTransaction();
     getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
     fragmentTransactionEditProfile.replace(R.id.frame, fragment);
     fragmentTransactionEditProfile.commit();
    

提交回复
热议问题