I need to change and update the ActionBar title according to the fragment that is called.
I used this example method:
=Method 1===============================
Activity > Codigo
public void setActionBarTitle(String title) {
getSupportActionBar().setTitle(title);
}
Fragmento > Codigo
public void onResume(){
super.onResume();
// Set title bar
((MainFragmentActivity) getActivity())
.setActionBarTitle("Your title");
}
=Method 2================================
Activity:
public void setActionBarTitle(String title){
YOUR_CUSTOM_ACTION_BAR_TITLE.setText(title);
}
Fragment:
((MainFragmentActivity) getActivity()).setActionBarTitle(YOUR_TITLE);
I have both ways and none updates the title in real time in real time.
But it is not working correctly, because it does not update the title according to the screen / fragment change. It takes a while to upgrade, and I wish it were in real time.
What is missing?