public Drawer buildForFragment() {
        if (mUsed) {
            throw new RuntimeException("you must not reuse a DrawerBuilder builder");
        }
        if (mActivity == null) {
            throw new RuntimeException("please pass an activity");
        }
        if (mRootView == null) {
            throw new RuntimeException("please pass the view which should host the DrawerLayout");
        }

        //set that this builder was used. now you have to create a new one
        mUsed = true;

        // if the user has not set a drawerLayout use the default one :D
        if (mDrawerLayout == null) {
            withDrawerLayout(-1);
        }

        //set the drawer here...

        View originalContentView = mRootView.getChildAt(0);

        boolean alreadyInflated = originalContentView.getId() == R.id.materialize_root;

        //only add the new layout if it wasn't done before
        if (!alreadyInflated) {
            // remove the contentView
            mRootView.removeView(originalContentView);
        } else {
            //if it was already inflated we have to clean up again
            mRootView.removeAllViews();
        }

        //create the layoutParams to use for the contentView
        FrameLayout.LayoutParams layoutParamsContentView = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
        );

        //add the drawer
        mRootView.addView(mDrawerLayout, layoutParamsContentView);

        //set the id so we can check if it was already inflated
        mDrawerLayout.setId(R.id.materialize_root);

        //handle the navigation stuff of the ActionBarDrawerToggle and the drawer in general
        handleDrawerNavigation(mActivity, false);

        //build the view which will be set to the drawer
        Drawer result = buildView();

        // add the slider to the drawer
        mDrawerLayout.addView(originalContentView, 0);

        //define id for the sliderLayout
        mSliderLayout.setId(R.id.material_drawer_slider_layout);
        // add the slider to the drawer
        mDrawerLayout.addView(mSliderLayout, 1);

        return result;
    }
public Drawer buildForFragment ( ) { if ( mUsed ) { throw new RuntimeException ( "you must not reuse a DrawerBuilder builder" ) ; } if ( mActivity == null ) { throw new RuntimeException ( "please pass an activity" ) ; } if ( mRootView == null ) { throw new RuntimeException ( "please pass the view which should host the DrawerLayout" ) ; } mUsed = true ; if ( mDrawerLayout == null ) { withDrawerLayout ( - 1 ) ; } View originalContentView = mRootView . getChildAt ( 0 ) ; boolean alreadyInflated = originalContentView . getId ( ) == R . id . materialize_root ; if ( ! alreadyInflated ) { mRootView . removeView ( originalContentView ) ; } else { mRootView . removeAllViews ( ) ; } FrameLayout . LayoutParams layoutParamsContentView = new FrameLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT ) ; mRootView . addView ( mDrawerLayout , layoutParamsContentView ) ; mDrawerLayout . setId ( R . id . materialize_root ) ; handleDrawerNavigation ( mActivity , false ) ; Drawer result = buildView ( ) ; mDrawerLayout . addView ( originalContentView , 0 ) ; mSliderLayout . setId ( R . id . material_drawer_slider_layout ) ; mDrawerLayout . addView ( mSliderLayout , 1 ) ; return result ; }
Build and add the DrawerBuilder to your activity

@return