TheLettuceMaster
TheLettuceMaster

Reputation: 15744

Turn Off ActionBar HomeButton for specific fragment

I want to disable the home button (left icon) in a particular fragment. I want it there of course, just not clickable. So I am trying to override the parent Activity by doing this in fragment:

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    MenuItem home = menu.findItem(android.R.id.home);
    home.setEnabled(false);

}

Is there another way to do this?

Note: Using ActionBarSherlock

Upvotes: 0

Views: 1761

Answers (2)

A--C
A--C

Reputation: 36449

You need to get an ActionBar instance then disable the home button like so:

getSherlockActivity().getSupportActionBar().setHomeButtonEnabled(false);

Upvotes: 3

Kevin Coppock
Kevin Coppock

Reputation: 134714

You should instead use the ActionBar to disable that button:

ActionBar actionBar = getSupportActionBar();
actionBar.setShowHomeAsUpEnabled(false);

Upvotes: 2

Related Questions