Allan Ramírez Allan Ramírez - 1 year ago 112
Android Question

How do I change the android actionbar title and icon

I'm trying to do some things on the Action Bar in Android

I've already added new items in the right side of the action bar

How can I change the left side of the action bar? I want to change the icon and the text, and I want to add a "Back Button" in the action bar for the other screens

Thanks in advance

Android Action Bar

Answer Source

This is very simple to accomplish

If you want to change it in code, call:

setTitle("My new title");

And set the values to whatever you please.

Or, in the Android manifest XML file:

<activity android:name=".MyActivity" 
       android:label="My new title" />  

To enable the back button in your app use:


The code should all be placed in your onCreate so that the label/icon changing is transparent to the user, but in reality it can be called anywhere during the activity's lifecycle.