• 11
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I am having difficulties trying to remove the back/home button from the action bar.

 getActionBar().setDisplayShowHomeEnabled(false);   //disable back button
 getActionBar().setHomeButtonEnabled(false);

In a older android phone, the back button is removed with these two code lines. However with the nexus 4, the back button still appears but is just disabled. Also I am just adding a menu item on the right that behaves like the back/home button replacing the back/home button. What am I missing?

Use getActionBar().setDisplayHomeAsUpEnabled(false) to remove the home button from the action bar.

  • 85
Reply Report
      • 1
    • It's a different method than setDisplayShowHomeEnabled. Did you try the code I posted? The setDisplayShowHomeEnabled method disables or enables the up affordance. The setDisplayHomeAsUpEnabled method puts the home button in the up affordance.
      • 1
    • thanks buddy sorry about that, obvious fustration here, and I will accept your answer when 5 minutes is up

If you're on API level 14 or above and are not using ActionbarSherlock, this code in onCreateOptionsMenu will disable the up button, remove the left caret, and remove the icon:

ActionBar actionBar = getActionBar();
if (actionBar != null) {
    actionBar.setHomeButtonEnabled(false); // disable the button
    actionBar.setDisplayHomeAsUpEnabled(false); // remove the left caret
    actionBar.setDisplayShowHomeEnabled(false); // remove the icon
}

source: https://stackoverflow.com/a/24967862/2887103

  • 16
Reply Report
      • 1
    • Answer worked for me. Just that my requirement was to hide, so added the above code without actionBar.setHomeButtonEnabled(false). Since its hidden, there is no need of disabling it.

None of the suggested solutions works for me.

But this one does:

// Hide the back button
mActionBar.setHomeAsUpIndicator(null);

It is a kind of a hack (last resort solution), though, so showing the action bar again means setting its icon back again.

  • 0
Reply Report

This code work for me

For remove navigation bar getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

For remove status bar getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

?But above code, it show again when you touch on screen, so if you want static state, combine this code.

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE);

  • 0
Reply Report