How to open any fragment after Navigation Drawer closed

My Fragment opens immediately after clicking the Navigation Drawer item. I want it to open after the navigation drawer has closed.

How do I open the fragment after the drawer was closed in the Navigation Drawer support library?

private void initNavigationView()
{
    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    drawerLayout = (DrawerLayout) findViewById(R.id.navigation_drawer);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.nav_open, R.string.nav_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View drawerView) {super.onDrawerClosed(drawerView)
        }

    };
    drawerLayout.post(new Runnable() {
            @Override
            public void run() {
                drawerToggle.syncState();
            }
        });
    drawerToggle.setDrawerIndicatorEnabled(true);
    drawerLayout.setDrawerListener(drawerToggle);
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem menuItem) {

                switch (menuItem.getItemId()) {
                    case R.id.tentang:
                        break;
                    case R.id.keluar:
                        finish();
                        break;
                }
                selectDrawerItem(menuItem);
                return true;
            }

            private void selectDrawerItem(MenuItem menuItem)
            {
                Fragment fragment = null;
                Class fragmentClass = null;

                switch (menuItem.getItemId())
                {
                    case R.id.fragment_home:
                        fragmentClass = com.wahyuapps.benux.fragment.fragmentHome.class;
                        break;
                    case R.id.fragment_distro_linux:
                        fragmentClass = com.wahyuapps.benux.fragment.fragmentDistroLinux.class;
                        break;
                }
                try {
                    fragment = (Fragment)fragmentClass.newInstance();
                }catch(Exception e){
                    e.printStackTrace();
                }
                FragmentManager fragmentManager = getSupportFragmentManager();
                fragmentManager.beginTransaction().replace(R.id.fragment_content, fragment).commit();
                menuItem.setChecked(true);
                setTitle(menuItem.getTitle());
                drawerLayout.closeDrawers();
            }
        });
}

What code do I put on this?
How to open fragment when the drawer is closed?
on my case, my fragment got opening after clicking the item. I want opening fragment with some delayed after drawer closed.

android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        TestingFragment hello = new TestingFragment();
        fragmentTransaction.add(R.id.mainlayout, hello, "HELLO");
        fragmentTransaction.commit();

with this you can call the fragment…and R.id.mainlayout is the rootlayout of your activity.

Edit 2

to open the fragment after some delay

Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
                @Override
                public void run() {

                    FragmentManager fragmentManager = getSupportFragmentManager();
                    fragmentManager.beginTransaction().replace(R.id.fragment_content, fragment).commit();
                    menuItem.setChecked(true);
                    setTitle(menuItem.getTitle());

                }
            }, 1000);

choose this import for the handler – import android.os.Handler;

I think you want to make a delay to open fragment. If you need to make fragment transition after drawer closed. Then you can achieve this by delaying your transition.

Your code should be like this.

navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case R.id.tentang:
                    break;
                case R.id.keluar:
                    finish();
                    break;
            }
            selectDrawerItem(menuItem);
            return true;
        }

        private void selectDrawerItem(MenuItem menuItem)
        {
            Fragment fragment = null;
            Class fragmentClass = null;

            switch (menuItem.getItemId())
            {
                case R.id.fragment_home:
                    fragmentClass = com.wahyuapps.benux.fragment.fragmentHome.class;
                    break;
                case R.id.fragment_distro_linux:
                    fragmentClass = com.wahyuapps.benux.fragment.fragmentDistroLinux.class;
                    break;
            }
            try {
                fragment = (Fragment)fragmentClass.newInstance();
            }catch(Exception e){
                e.printStackTrace();
            }
                changeFragment(fragment);
                menuItem.setChecked(true);
                setTitle(menuItem.getTitle());
                drawerLayout.closeDrawers();
            }
        });

Create a method to change fragment.

 public void changeFragment(final Fragment fragment){
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                FragmentManager fragmentManager = getSupportFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.fragment_content, fragment).commit();
            }
        }, 400);
    }

I just entered 400 milliseconds delay in transition. Change it by your wish.

Hope it helps:)