0

I have to disable the home button in my android application. I have an Actionbar Sherlock and setting DisplayHomeAsUpEnabled didn't work.

Here is my code:

ActionBar ab =getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(false);

Thanks for your help!

bjtitus
  • 4,231
  • 1
  • 27
  • 35
Halo
  • 729
  • 1
  • 8
  • 18
  • Are you talking about home button of phone? – Apurva Mar 11 '15 at 03:39
  • As far as I know the home button on the action bar will only work if you tell it what to do, it does not work by default. Which leads me to think you are maybe defining these actions somewhere else? – Joe Maher Mar 11 '15 at 03:44
  • @Apurva Yes, that's it... home button of phone. – Halo Mar 11 '15 at 03:49
  • No it's not possible! – Apurva Mar 11 '15 at 03:50
  • @JoeMaher I wrote that code in onCreate method. As I said, it doesn't work... bro – Halo Mar 11 '15 at 03:50
  • @Apurva Really? You mean there is no way to do unclickable the home button of the Phone... – Halo Mar 11 '15 at 03:52
  • Wait you mean the home button of the phone? Not on the action bar? If so, of course their isn't, it would lead to users being held hostage within the application – Joe Maher Mar 11 '15 at 03:53
  • You're question is worded as if you are speaking of the home button on the action bar, not the device itself. Hence mine and some of the other comments – Joe Maher Mar 11 '15 at 03:54

1 Answers1

0

You can do this -

ab.setHomeButtonEnabled(false);
ab.setDisplayHomeAsUpEnabled(false);

If this doesn't work then you can override the menu click method because home button act as a menu-

    @Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
    //Do nothing
        return false;
    }
    return super.onOptionsItemSelected(item);
}
ARGHA
  • 31
  • 2