Reputation: 11
Activity Label tag Hi There. This question might have been answered before but i couldn't find any clear directions. I am new to android and currently learning the basics.
I am trying to change the activity label tag but somehow i couldn't find a way to do so. I have created multi screen app and would like to change each screen label as per the category. My apologies if my question is not clear.
Thank you
Upvotes: 1
Views: 5782
Reputation: 3193
You can write it in your activity onCreate:
setTitle("Your Title");
Or do it in AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:label="Your Title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 0
Reputation:
In your manifest type android :lable ="....." Under the specific activity . If you are trying to have label from any text view in layouts ,then you can think of above answers.
Upvotes: 1
Reputation: 11
The title setting mechanism will depend on your layout structure and the kind of AppBar/Toolbar you are using.
If you are using CoordinatorLayout
with a nested CollapsingToolbarLayout
,
the you'll have to call setTitle()
on the CollapsingToolbarLayout
instance.
If you are using an AppCompatActivity
you can change the title by calling:
getSupportActionBar().setTitle("New Title");
If you are using a custom Toolbar element inside your layout, you'll have to set set your title on a Toolbar, then set the Toolbar as Activity's ActionBar like so:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("New toolbar Title");
setSupportActionBar(toolbar);
Note: you'll have to call setSupportActionBar(toolbar);
AFTER you set the title.
Upvotes: 0
Reputation: 33
You can change the title of activities by calling setTitle():
setTitle("My Title")
Upvotes: 0
Reputation: 698
Typically,
setTitle("myTitle");
should work.
In some cases, though, you may need to call
getSupportActionBar().setTitle("myTitle");
This may be necessary depending on how you designed your activity.
Upvotes: 0