title: Android Navigation View click listener not working
body: <p>I created the Activity with the Wizard.
  I deleted what I am not interested in, for example, the floating action button.</p>
  
  <p>Created my custom items in the <strong>activity_main_drawer.xml</strong></p>
  
  <p>The wizard created the <strong>onNavigationItemSelected</strong> function (<em>see code below</em>) and I added my code so it quits the activity and goes back to the Login Screen.</p>
  
  <p>So I don't know why, I see nothing interesting in the logcat so this is a logical problem. I am a newbie and Navigation View scares me a lot... <strong>Let me know if I missed anything you need.</strong> </p>
  
  <pre><code>package com.skrefi.googleplaycopy;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.view.View;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.Toast;
  
  import com.google.firebase.auth.FirebaseAuth;
  
  public class MainActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
      private FirebaseAuth firebaseAuth;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          firebaseAuth = FirebaseAuth.getInstance();
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          drawer.addDrawerListener(toggle);
          toggle.syncState();
  
          NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
          navigationView.setNavigationItemSelectedListener(this);
  
      }
  
  
      //Don't know what this is
      @Override
      public void onBackPressed() {
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          if (drawer.isDrawerOpen(GravityCompat.START)) {
              drawer.closeDrawer(GravityCompat.START);
          } else {
              super.onBackPressed();
          }
      }
  
      //Don't know what this is either
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      //In case I need it for the admin activity &gt;&gt; the 3 dots pop down thingy &lt;&lt;
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
  
          MakeToast("SOMETHING");
  
          switch (item.getItemId()){
              case R.id.action_settings:
                  MakeToast("Settings button clicked");
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  
      @SuppressWarnings("StatementWithEmptyBody")
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          // Handle navigation view item clicks here.
          switch(item.getItemId()){
              case R.id.item_signout:
                  firebaseAuth.getInstance().signOut();
                  MakeToast("Signed out!");
                  finish();
                  startActivity(new Intent(MainActivity.this, LoginActivity.class));
                  break;
          }
  
          //DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          //drawer.closeDrawer(GravityCompat.START);
          return true;
      }
  
      public void MakeToast(String text) {
          Toast.makeText(this, text, Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>So it may be confusing if I set the <strong></strong> visibility to <strong>gone</strong> and I get use the layout I want right in this layout file because I get the screen without the toolbar, this is what I want. AND I want to keep that as well for the admin part, to check later in if the user is me, and if so, I get a new item in the drawer called Admin Activity which simply set the  thingy visibility to <em>visible</em> so i get the admin screen.</p>
  
  <p>Here is what you (@) asked for:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"&gt;
  
      &lt;!--This is for a potential admin screen--&gt;
  
      &lt;include
          android:id="@+id/include_toolbar_with_threedots_settings"
          layout="@layout/app_bar_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:visibility="gone" /&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header_main"
          app:menu="@menu/activity_main_drawer" /&gt;
  
      &lt;android.support.constraint.ConstraintLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="This is for test"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>