I have an actionbar with a button on the left, a logo in the center and another button on the right. However, whenever I launch a new intent or activity, the whole actionbar “refresh”.
I understand that I need to use Fragments. However, how do I go about implementing that? I saw a lot of examples are fragments with tabs. But I just want my actionbar to remain fixed as I move from one activity to another. I do not have any tabs at all.
Can you please give me examples on how do I go about implementing it? If I have activity A and B. Does that mean I should have 2 fragments?
Many thanks!
If you want to have only 1 action-bar for all activities you will create a
FragmentActivityclass in which you will display Fragments. Only thisFragmentActivitywill have a action bar.You can add, remove, replace Fragments in its(FragmentActivity’s) body and change it when you want, like this
Here
realViewSwitcher_bodyis initial View present inFragmentActivitya I replaced it with a Fragment (English.newInstance()its a method with is returning a fragment instance)This is the whole Scenario either you use Tabs or View-Pager etc and up to my knowledge and experience you can not use Intents for activities having only one Action-bar.