In my app, I change the title in the ActionBar from each fragment displayed. When I first start my apps, I got a list of requests, so my title is \"My requests (20)\".
T
put setTitle()
in onCreateOptionsMenu
helps me to solve this problem.
In your fragment add setHasOptionsMenu(true);
in onCreateView(){}
Then override onCreateOptionsMenu()
.
Example:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
// put getActivity in onCreateOptionsMenu will not return null
if (getActivity() != null) {
getActivity().setTitle(getResources().getString(R.string.Studies));
}
}
Reference: How to display android actionbar title without truncation occurring