Hamburger Icon does not show in Navigation Drawer Fragment

前端 未结 2 1239
耶瑟儿~
耶瑟儿~ 2021-02-08 22:53

I am using a Fragement for navigation drawer and hence can\'t use onPostCreated to call syncState

public class NavigationDrawerFragment extends Frag         


        
相关标签:
2条回答
  • 2021-02-08 23:31

    I had this problem as well. For me, importing android.support.v7.app.ActionBarDrawerToggle instead of android.support.v4.app.ActionBarDrawerToggle fixed it. You also have to remove the R.drawable.ic_drawer argument when you define mDrawerToggle:

    mDrawerToggle = new ActionBarDrawerToggle( getActivity(), mDrawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close )

    If that doesn't work, try some of the answers to this question.

    0 讨论(0)
  • 2021-02-08 23:41

    The accepted answer was not solving it for me, I found out I had the wrong override for onPostCreate

    @Override
    public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onPostCreate(savedInstanceState, persistentState);
        mDrawerToggle.syncState();
    }
    

    It must be

    @Override
    public void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        mDrawerToggle.syncState();
    }
    
    0 讨论(0)
提交回复
热议问题