I have 1 action with 3 fragments inside (Home-Login-RestorePass). HomeFragment is displayed first, and the other two are hidden. I want the name of the ActionBar to change depending on which fragment is displayed.
I try in my activity with:
public void setActionBarTitle(String title){ getSupportActionBar().setTitle(title); } @Override public void onResume() { super.onResume();
and fragments have the same:
@Override public void onResume() { super.onResume();
But that will not work. It always shows R.string.fragment_login in the header.
I use FragmentTransaction to transition a fragment:
btnLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right); HomeFragment homeFragment = (HomeFragment) getFragmentManager().findFragmentById(R.id.fragmentHome); LoginFragment loginFragment = (LoginFragment) getFragmentManager().findFragmentById(R.id.fragmentLogin); ft.hide(homeFragment).addToBackStack(null); ft.show(loginFragment).addToBackStack(null).commit(); } });
Also, if I could appear, the button with the (Back) arrow on the ActionBar would be large depending on the fragment.
Thank you for your time! Best wishes.
android android-actionbar android-fragments
Maverick.pe
source share