Benjamin Faulkner
Benjamin Faulkner

Reputation: 31

How to change the toolbar's title in android app?

My android app has a toolbar and I wan to change the title of it. I used toolbar.setTitle() but it is not working... Please help. What should I do? I tried getSupportActionBar().setTitle() but it doesn't work.

Upvotes: 1

Views: 164

Answers (2)

Sandeep dhiman
Sandeep dhiman

Reputation: 1921

Use below code to set the title

 Toolbar   mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);            
setSupportActionBar(mActionBarToolbar);
getSupportActionBar().setTitle("My title");

Upvotes: 1

Sky
Sky

Reputation: 1433

Try to use this.setTitle(title); in onCreate() method.

Upvotes: 6

Related Questions