williamj949
williamj949

Reputation: 11316

Change ActionBar Title

My main Activity consists of a fragment.I am setting up the action bar title on onResume() method of Activity as

@Override
    protected void onResume() {
        super.onResume();
        getActionBar().setTitle("My Account");
    }

which shows the action bar title as "My Account".And when i call a fragment i set the title on onResume() method of fragment as

@Override
    public void onResume() {
        super.onResume();
        getActivity().getActionBar().setTitle("Connected Accounts");
    }

which displays the title as 'Connected Accounts'.However when i go back to the activity it still displays the title as 'Connected Accounts',whereas it should display as 'My Account'. Please help i know there is something missing in this peculiar case.Thanks

Upvotes: 1

Views: 940

Answers (1)

Sats
Sats

Reputation: 885

Just override onDetach() in your Fragment Class. add this code in your fragment.

@Override
public void onDetach() {
    // TODO Auto-generated method stub
    super.onDetach();
    getActionBar().setTitle("My Account");
}

Upvotes: 5

Related Questions