Answer the question
In order to leave comments, you need to log in
How to dynamically change the Toolbar when working with fragments?
Hello. For a little bit I'm trying to delve into android development. I am making a case app.
There is a single activity, one of the fragments is the application menu, by clicking on each of the items in place of the "menu" fragment, another fragment opens with its own toolbar. Each toolbar differs from the others in its title and pop-up menu, in fact, how to do it more competently from the point of view of architecture (or is the option with one activity a priori considered incorrect)?
Answer the question
In order to leave comments, you need to log in
In activation during initialization:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null){
toolbar.setTitle(...);
setSupportActionBar(toolbar);
...
}
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
if (toolbar != null)
toolbar.setTitle(...);
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question