title: My Navigation Drawer on item click listener not worked
body: <p>I want to show navigation drawer navigation drawer in main activity it shows but when i used on click listener it cant work. I want to change fragment on click listener in navigation drawer. I tried alot but it cant work.Kindly also guide me how can i hide navigation drawer in different fragments and also guide me how can i open again navigation drawer on custom design button click.</p>
  
  <pre><code>package com.sprintsolutions.palmtree.activity;
  
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.ActionBarDrawerToggle;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.appcompat.widget.Toolbar;
  import androidx.core.view.GravityCompat;
  import androidx.drawerlayout.widget.DrawerLayout;
  import androidx.fragment.app.Fragment;
  
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.Gravity;
  import android.view.MenuItem;
  import android.widget.Toast;
  
  import com.google.android.material.navigation.NavigationView;
  import com.sprintsolutions.palmtree.R;
  import com.sprintsolutions.palmtree.fragment.ForgetPasswordFragment;
  import com.sprintsolutions.palmtree.fragment.HomeFragment;
  import com.sprintsolutions.palmtree.fragment.LoginStartFragment;
  
  public class FragmentContainerActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
  
      private DrawerLayout mDrawerLayout;
      private ActionBarDrawerToggle mToggle;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_fragment_container);
  
  
  
          final Fragment menuPractiseFragment=new HomeFragment();
          getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer,
                  menuPractiseFragment,menuPractiseFragment.getClass().getSimpleName())
                  .addToBackStack(null).commit();
  
          mDrawerLayout=(DrawerLayout)findViewById(R.id.activity_main);
          mToggle=new ActionBarDrawerToggle(this,mDrawerLayout,R.string.open,R.string.close);
          mDrawerLayout.addDrawerListener(mToggle);
          mToggle.syncState();
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          NavigationView navigationView=(NavigationView)findViewById(R.id.navvv);
          navigationView.setNavigationItemSelectedListener(this);
  
          navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
              @Override
              public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                  int id = menuItem.getItemId();
  
                  if (id == R.id.db) {
                      Toast.makeText(FragmentContainerActivity.this, "Dashboard Activity", Toast.LENGTH_SHORT).show();
                  } else if (id == R.id.search) {
  
                      Toast.makeText(FragmentContainerActivity.this, "Search Activity", Toast.LENGTH_SHORT).show();
                  } else if (id == R.id.event) {
  
                      Toast.makeText(FragmentContainerActivity.this, "Event aCTIVITY", Toast.LENGTH_SHORT).show();
                  }
  
                  mDrawerLayout.closeDrawer(GravityCompat.START);
                  return true;
              }
          });
  
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          if (mToggle.onOptionsItemSelected(item)){
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
  
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
  
  
          return false;
      }
  
  }
  </code></pre>