Search code examples
androidsetandroid-actionbar

How to make all activities(except MainActivity) have ActionBar/Toolbar at once with the title of the Activity and a back button?


I have the following MainActivity:

enter image description here

When I click on "Congreso" button the following activity appears:

enter image description here

And when I click on "Programa" button the following activity appears:

enter image description here

All activities except MainActivity have an action bar with a back button, a title of the activity aligned at the same place each time and the same color of the action bar. In my case I want the color to be blue. My question is, is there a way to set that behaviour on a single place in the application and it to apply to all the activities except for the MainActivity so that if some day I want to change the color of the action bar or the alignement of its title I don't have to go to all activities one by one and change it.

P.S.: I don't know if what is on the screenshots is an action bar or it is a toolbar. If you give me a solution with a toolbar it is OK too.


Solution

  • Please make a BaseActivity , Use the Action bar in BaseActivity , Handle "Back Image Click" there and just set the respective title name in Individual Activities. All the Activities will extends BaseActivity excluding MainActivity