Answer the question
In order to leave comments, you need to log in
How to make a dynamic toolbar and implement it in one place?
Good afternoon, I have one activity with a contentMain that is filled with fragments. Is it possible somehow in the main activity to track changes in the life cycle so that in one place the toolbar can be changed dynamically, for example like this:
public static void dynamicToolbar(Activity activity){
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.contentMain);
Toolbar toolbar = activity.findViewById(R.id.toolbar);
if (fragment instanceof GoodsInfoFragment){
toolbar.setTitle("Информация о товаре");
}else if(fragment instanceof GoodsFragment){
//dosomething();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question