How to change title of Activity in Android?


Question

I am using

Window w = getWindow();
w.setTitle("My title");

to change title of my current Activity but it does not seem to work.

Can anyone guide me on how to change this?

1
212
3/5/2014 10:07:26 AM

Accepted Answer

Try setTitle by itself, like this:

setTitle("Hello StackOverflow");
478
2/4/2010 9:36:57 AM

Just an FYI, you can optionally do it from the XML.

In the AndroidManifest.xml, you can set it with

android:label="My Activity Title"

Or

android:label="@string/my_activity_label"

Example:

    <activity
        android:name=".Splash"
        android:label="@string/splash_activity_title" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon