0

How do I start my app with the navigation drawer open? I am not asking about setting preferences. I imagine I have to use openDrawer. But I don't know how. The following does not work:

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);   
mDrawerLayout.openDrawer(mDrawerList);

Neither does the following

mDrawerLayout.openDrawer(mDrawerList);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
learner
  • 11,490
  • 26
  • 97
  • 169
  • Where are you putting your code? it should be on the onResume part of your activity. – rui.mendes Nov 15 '13 at 15:23
  • Is your Navigation Drawer already working? – Steve Benett Nov 15 '13 at 15:24
  • check the docs http://developer.android.com/training/implementing-navigation/nav-drawer.html – Raghunandan Nov 15 '13 at 15:25
  • 1
    `openDrawer()` works for me. What does "the following does not work mean?" What behavior do you observer? Does it crash, or simply not open? – Bryan Herbst Nov 15 '13 at 15:26
  • My code is in onCreate just as in the android tutorial. The drawer is indeed working. But I want the drawer to be open when the user starts my app. Right now it is closed and I have to pull it. – learner Nov 15 '13 at 16:16
  • @Tanis.7x `openDrawer` takes a parameter. The example I show you is not working for me. My example is exactly as in the sample library referred in http://developer.android.com/training/implementing-navigation/nav-drawer.html#top – learner Nov 15 '13 at 16:18
  • I'm aware it takes a parameter. For brevity's sake, I omit arguments when I only need to reference a method's name in a comment. Another user suggested moving it to onResume, have you tried that? – Bryan Herbst Nov 15 '13 at 16:30
  • ha. Thank you. putting it in onResume works. @Tanis.7x my comment was meant to ask which parameter should I pass it as there are two overloaded versions of the method. – learner Nov 15 '13 at 16:44

0 Answers0