max59
max59

Reputation: 606

Display an item's name as the title on the Action Bar

I'm working on an app that displays all the contact names in a ListView. On click, the app displays all the details of that contact in another activity. I want to display the contact name as a title on the action bar on the other activity, so that the user can see the contact name on the action bar that he clicked on.

Upvotes: 0

Views: 322

Answers (1)

Shobhit Puri
Shobhit Puri

Reputation: 26007

In the other activity inside on create you can do something like:

String name; // Get the name from the exttra of the intent or howsoever you are getting the name
ActionBar ab = getActionBar();
ab.setTitle(name);

You can replace name with the contact name that you can pass as extras with the intent or by other ways.

Upvotes: 2

Related Questions