title: How do I close a navigation drawer after an item is selected?
body: <p>I have implemented a navigation drawer and everything functions properly. The navigation drawer contains a listview and when an item is selected, the main fragment is replaced properly.</p>
  
  <p>This is the onClickListener code:</p>
  
  <pre><code>mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          HeaderViewListAdapter headerView = (HeaderViewListAdapter) parent.getAdapter();
          AccountAdapter adapter = (AccountAdapter) headerView.getWrappedAdapter();
          Cursor cursor = adapter.getCursor();
  
          if(cursor != null &amp;&amp; cursor.moveToPosition(position)){
              ((NavigationDrawerCallbacks) getActivity()).onNavigationDrawerItemSelected(cursor.getLong(cursor.getColumnIndex(ID_COLUMN)));
          }
      }
  });
  </code></pre>
  
  <p>And in my activity, the onNavigationDrawerItemSelected method is like this:</p>
  
  <pre><code>@Override
  public void onNavigationDrawerItemSelected(long accountId) {
      // update the main content by replacing fragments
      FragmentManager fragmentManager = getSupportFragmentManager();
      fragmentManager.beginTransaction()
              .replace(R.id.mainFragment, AccountDetailFragment.newInstance(accountId))
              .commit();
  }
  </code></pre>
  
  <p>As I said, this functions, but the navigation drawer remains open. It's a hassle for the user to have to select an account from the listview and then have to close the drawer to see the main fragment, so how can I have it close automatically, so that when an item is selected the only visible element is the main fragment (and everything inside of it)?</p>