VikaS GuttE
VikaS GuttE

Reputation: 1704

How to retrieve title of action bar and assign it to text view?

How to retrieve title of Action bar and assign it to text view?

I tried below code but it's not working...

Code:

t1 = rootView.findViewById(R.id.textview1);
t1.setText(getActivity().getActionBar().getTitle().toString());

[1]: https://i.imgur.com/I5DFV.jpg "tooltip"

Upvotes: 1

Views: 214

Answers (2)

karan
karan

Reputation: 8853

You can get the title from Support ActionBar, Use below code.

YourActivity.this.getSupportActionBar().getTitle();

Upvotes: 1

secret paladin
secret paladin

Reputation: 222

for java:

getActivity().getTitle()

for kotlin:

activity.title

Upvotes: 1

Related Questions