Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set title bar name of a activity

I'm trying to change my applications activity menu bar title. I managed to change font as follows. Anyone help me to change the name of the title. It may be just a one line, but I can't figure it out.

int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    TextView actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle);
    if(actionBarTitleView != null){
        actionBarTitleView.setTypeface(typeFace);
    }
like image 605
Channa Avatar asked Dec 17 '25 17:12

Channa


2 Answers

Try this

getActionBar().setTitle("Your title");

or this if you use appcompat-v7

getSupportActionBar().setTitle("Your title");

like image 75
Mattia Maestrini Avatar answered Dec 20 '25 09:12

Mattia Maestrini


You can set the title in action-bar using AndroidManifest.xml. Just add label to the activity. Like

<activity
       android:name=".DownloadActivity"
       android:label="Your Title"
       android:theme="@style/AppTheme" />
like image 31
Ricky Avatar answered Dec 20 '25 09:12

Ricky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!