user8452856
user8452856

Reputation: 45

Change the App name to some other text in the top bar

Can please someone tell me how to change the App name in the top bar of my android App that gets displayed by default to some other text? I have seen this in a few Apps I used before. I'm building my first Android App and don't have that much experience with this stuff... thank you :)

Upvotes: 2

Views: 1364

Answers (3)

Joshua
Joshua

Reputation: 651

If you are using the new support library, you should use this:

Toolbar toolber = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(Toolbar);
getSupportActionBar().setTitle("App Title");

Upvotes: 0

Anil Shrestha
Anil Shrestha

Reputation: 1200

after setContentView(R.layout.layout_name); simply add

setTitle("title_name");

this will change the name of your current activity in top bar or toolbar and i think your activity should extend AppCompactActivity

Upvotes: 3

Lukas Schröder
Lukas Schröder

Reputation: 344

it is easier if you convert the actionbar (which I think is the bar you mean) into a toolbar if you want to do further modifications to it (as I assume):

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);    
setSupportActionBar(toolbar);

to change the title then simply call actionbar.setTitle as shown here:

actionBar = getSupportActionBar();
    actionBar.setTitle("Your Title");

and if you want a subtitle add:

    actionBar.setSubtitle("Your Subtitle");

Upvotes: 0

Related Questions