Reputation:
Seems pretty simple question, but could't find any answer. How to change the toolbar title.
The toolbar is created by AppCompat Activity,not a custom created one. It has the app name as default.I would like to change its Name corresponding to the action the activity performs.
Note : I can change custom toolbar title using the below code,so please i am not looking for that.
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle("My Title");
Upvotes: 5
Views: 6953
Reputation: 3539
Set ActionBar
title based on your need
ActionBar ab = getActionBar();
ab.setTitle("My Title");
Upvotes: 0
Reputation: 6405
You can set default Toolbar
title as following:
YourActivity.this.setTitle("Your Title");
For fragment:
getActivity().setTitle("Your Title");
Upvotes: 11