Default Android Studio Navigation Drawer Activity Template does not show hamburger icon, only arrow icon

This person basically works on the same problem as mine , however the solution provided does not help, and it does not work for me, since my code is actually calling mDrawerToggle.sycnState () (in deferred Runnable).

I also tried adding it to onActivityCreated in my fragment, which seems to be doing nothing. Not knowing exactly what syncState does, I cannot say if it synchronizes the open state (which makes the template code by default), and then it never syncs again when the box is manually closed.

I would publish the code, but you can verify this by creating a new project in Android Studio (1.2.2), selecting "Activity of the navigation box", and then just starting the project - no changes are required. You will see that the only symbol is the arrow <-. I even set breakpoints to test the ActionBarDrawerToggle object, which actually has a hamburger icon in its memory for drawing the icon, waving me even more!

I am here here.

+6
source share
1 answer

I just figured out a solution if anyone else has this problem:

Change the import at the top of the snippet from

import android.support.v4.app.ActionBarDrawerToggle; 

to

 import android.support.v7.app.ActionBarDrawerToggle; 

then change the code in setUp from

 mDrawerToggle = new ActionBarDrawerToggle( getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) 

to

 mDrawerToggle = new ActionBarDrawerToggle( getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) 
+20
source

Source: https://habr.com/ru/post/989022/


All Articles