Why is my navigation drawer empty?

For android's navigation drawer, why setDisplayHomeAsUpEnabled is required

  • getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.open_drawer, R.string.close_drawer ); mDrawerLayout.setDrawerListener(mDrawerToggle); This is part of my code I'm using to set the navigation drawer and the app icon to toggle it. I'm very confused in that why is it required to setDrawerListener when already while constructing the DrawerToggle object we have specified the DrawableLayout in the constructor. Second, why is the setDisplayHomeUpEnabled required when we are actually not enabling it. And without it, why isn't the ic_drawer displayed? Thanks.

  • Answer:

    From documentation https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html ActionBarDrawerToggle can be used directly as a DrawerLayout.DrawerListener, or if you are already providing your own listener, call through to each of the listener methods from your own. So setDrawerListener method is for setting drawer listener, it could be custom one or you could use your ActionBarDrawerToggle object because it already implements DrawerLayout.DrawerListener. Setting setDisplayHomeUpEnabled is showing < sign in your action bar but when using navigation drawer it shows three lines. This is how it is implemented.

emotionull at Stack Overflow Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.