0

The action bar for the 2 activities I have don't have a label. I want the main screen to have the app name and the next screen to have a different label. Here is my manifest file:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/MSTheme" >

        <activity
            android:name="com.android.recipme.MainScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.android.recipme.MyRecipes"
            android:label="@string/my_recipes" >
        </activity>
    </application>

I've searched for some answers and can't seem to get anything right. Please help thanks!

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
TrackDave
  • 279
  • 2
  • 14

1 Answers1

0

To change the title of the desired activity, including the following line should be what you want, usually onCreate( ) is where you'd want to put this:

setTitle("SetYourTitle Here");

You can refer to this thread for more information: How to change the text on the action bar

Community
  • 1
  • 1
jak10h
  • 519
  • 4
  • 11
  • There's no way of doing this in xml? – TrackDave Feb 17 '14 at 22:01
  • When you say "The action bar for the 2 activities I have don't have a label", does that mean the ActionBar (where the title appears) is not showing up? – jak10h Feb 18 '14 at 00:15
  • Yes that's correct. It's just blank, but if I put android:label="@string/app_name" under application, it will add the label. Problem is, it will add the app_name to all screens and I was hoping to have different label for the 2 screens. Hope that makes sense. Thanks. – TrackDave Feb 18 '14 at 11:10
  • You can try removing the line android:theme="@style/MSTheme" and see if that helps. Otherwise I would put android:label="@string/app_name" under application to make the title bar appear and then call setTitle("SetYourTitle Here") in your desired activity. – jak10h Feb 19 '14 at 02:37