Reputation: 35
in actionbar home fragment bottomnavigation
in action bar favorite fragment bottomnavigation
how to hide or remove actionbar icon when moving to favorite fragment?
Upvotes: 1
Views: 328
Reputation: 8335
You just need to make your FavoriteFragment
options menu aware and then in onCreateOptionsMenu
, simply clear the menu
. this can be done by updating FavoriteFragment
with following changes
In onCreateView
, call setHasOptionsMenu(true)
to receive options menu related callbacks in Fragment
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Allows your fragment to receive options menu related callbacks (onCreateOptionsMenu etc)
setHasOptionsMenu(true)
...
}
now override onCreateOptionsMenu
and clear the already populated menu
as
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
menu.clear()
}
Upvotes: 3