code: public void setUp(int fragmentId, DrawerLayout drawerLayout) {
          mFragmentContainerView = getActivity().findViewById(fragmentId);
          mDrawerLayout = drawerLayout;
  
          // set a custom shadow that overlays the main content when the drawer opens
          mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
          // set up the drawer's list view with items and click listener
  
          ActionBar actionBar = getActionBar();
          actionBar.setDisplayHomeAsUpEnabled(true);
          actionBar.setHomeButtonEnabled(true);
  
          // ActionBarDrawerToggle ties together the the proper interactions
          // between the navigation drawer and the action bar app icon.
          mDrawerToggle = new ActionBarDrawerToggle(
                  getActivity(),                    /* host Activity */
                  mDrawerLayout,                    /* DrawerLayout object */
                  R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
                  R.string.drawer_open,  /* "open drawer" description for accessibility */
                  R.string.drawer_close  /* "close drawer" description for accessibility */
          ) {
              @Override
              public void onDrawerClosed(View drawerView) {
                  super.onDrawerClosed(drawerView);
                  if (!isAdded()) {
                      return;
                  }
  
                  getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
              }
  
              @Override
              public void onDrawerOpened(View drawerView) {
                  super.onDrawerOpened(drawerView);
                  if (!isAdded()) {
                      return;
                  }
  
                  getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
              }
          };
  
          // Defer code dependent on restoration of previous instance state.
          mDrawerLayout.post(new Runnable() {
              @Override
              public void run() {
                  mDrawerToggle.syncState();
              }
          });
  
          mDrawerLayout.setDrawerListener(mDrawerToggle);
      }
docs: Users of this fragment must call this method to set up the navigation drawer interactions.
  
  @param fragmentId   The android:id of this fragment in its activity's layout.
  @param drawerLayout The DrawerLayout containing this fragment's UI.