I use the Navigation Drawer from the standard Google example:

  if (mDrawerLayout.isShown()) { mDrawerLayout.closeDrawers(); } else { //mDrawerLayout.openDrawer(Gravity.RIGHT); //mDrawerLayout.openDrawer(Gravity.LEFT); //mDrawerLayout.openDrawer(mDrawerLayout); //mDrawerLayout.openDrawer(mDrawerLayout.getForegroundGravity()); } 

In this code, the part that closes the Navigation Drawer works without problems, but none of the methods that I call to open, does not work: either they are simply ignored, or I use them incorrectly (uncommented in turn).

So I initialize the objects to work with Navigation Drawer :

 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_ab_app, /* nav downloaded_list icon to replace 'Up' caret */ R.string.vk_retry, /* "open downloaded_list" description */ R.string.vk_new_post_settings /* "close downloaded_list" description */ ) { /** * Called when a downloaded_list has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); //getActionBar().setTitle("closed"); } /** * Called when a downloaded_list has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); //getActionBar().setTitle("opened"); } }; 
  • Explain "not one of the induced closing methods does not work." It seems you are ochepeyatsya. - Yuriy SPb
  • I will try to call this in a third-party thread: new Thread () {public void run () {SystemClock.sleep (100); HomeActivity.this.runOnUiThread (new Runnable () {@Override public void run () {mDrawerLayout.closeDrawers ();}}); }} .start (); - Djangorussia

1 answer 1

Try the openDrawer() method without parameters. It works for me.

  • without parameters, it gives an error when compiling; well, it's simple, if you leave it open in the editor. But thanks for trying + - Jaroslav Movchan
  • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky