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 :)
Asked
Active
Viewed 1,033 times
1
-
In order for someone to answer you, you have to show what you researched, how you tried to implement and the issues you faced. – BogdanC Aug 15 '17 at 14:04
-
Check Solution here : https://stackoverflow.com/questions/3438276/how-to-change-the-text-on-the-action-bar – Akshay Prabhakar Aug 15 '17 at 14:05
-
@BogdanC sorry I didn't know that I had to be that specific :/ – user8452856 Aug 15 '17 at 14:06
3 Answers
3
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

Anil Shrestha
- 1,180
- 11
- 16
-
-
-
It worked in Kotlin too - `MainActivity.kt` in function `onCreate` – Vinay Verma May 20 '21 at 15:21
0
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");

Lukas Schröder
- 344
- 1
- 2
- 16
-
yes you need to put this in your onCreate method of your activity you want this to happen in – Lukas Schröder Aug 15 '17 at 14:04
0
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");

Joshua
- 589
- 1
- 5
- 19