The behavior of the Action Bar (also known as the Toolbar) has changed in more recent versions of Android. In earlier versions, the Action Bar was part of the Activity layout, and replacing a fragment did not affect the Action Bar. However, in more recent versions, the Action Bar is tied to the current Fragment, and changing fragments can result in the Action Bar being replaced as well.
To fix this issue, you need to make sure that each Fragment has its own Action Bar or Toolbar. Use setHasOptionsMenu(true) in each Fragment to specify that it should have its own menu. Also, make sure that you are inflating the correct menu in each Fragment's onCreateOptionsMenu() method. Finally, if you are using Navigation Components, consider using the Toolbar provided by the Navigation Component to ensure consistent behavior across fragments.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-24 08:58:17 +0000
Seen: 20 times
Last updated: May 24 '23
How to make a JMenu function similarly to a JButton?
After executing an action query in MS Access, why am I unable to save the module?
How can I make the game in renpy wait for player action before progressing?
What is the $action output in an INSERT statement?
What is the purpose of Custom Order Action in WooCommerce?
How can an edit form be generated using ASP.Net MVC 2 scaffolding?
How can the boolean variables be represented over time using a bar graph?