How to close navigation drawer when an item is pressed from it?

Got it!

private DrawerLayout mDrawerLayout;
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.closeDrawers();

Working perfectly fine.


closeDrawer();//when you want to call

public void closeDrawer() {
    if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
        mDrawerLayout.closeDrawer(GravityCompat.START);
    }
}

DrawerLayout mDrawerLayout= (DrawerLayout) findViewById(R.id.drawer_layout)

closeDrawer(); // called when you want to close

public void closeDrawer() {
  if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
    mDrawerLayout.closeDrawer(GravityCompat.START);
  }
}

For me this one worked -

mDrawerLayout.closeDrawer(Gravity.START, false);