title: NullPointerException on MenuItem
body: <p>I have a problem with Null-pointer. I am trying to do next:
  When my app is launched, it checks if user is logged in, and if it is yes, I am changing my UI <strong>updateUI();</strong></p>
  
  <p>So I can't change visibility of my <strong>navLogIn</strong> <strong>navNewAcc</strong> and <strong>navLogOut</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener {
  
  private FirebaseAuth mAuth;
  
  MenuItem navLogIn;
  MenuItem navNewAcc;
  MenuItem navLogOut;
  TextView navHeaderName;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      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);
  
      mAuth = FirebaseAuth.getInstance();
  
      navLogIn = (MenuItem) findViewById(R.id.nav_log_in);
      navNewAcc = (MenuItem) findViewById(R.id.nav_new_account);
      navLogOut = (MenuItem) findViewById(R.id.nav_log_out);
      navHeaderName = (TextView) findViewById(R.id.nav_header_name);
  
      // Kreiranje liste
      ListView listView=(ListView)findViewById(R.id.listViewMain);
      CategoryAdapter categoryAdapter = new CategoryAdapter(MainActivity.this);
      listView.setAdapter(categoryAdapter);
  
  }
  
  @Override
  public void onStart() {
      super.onStart();
      // Check if user is signed in (non-null) and update UI accordingly.
      FirebaseUser currentUser = mAuth.getCurrentUser();
      updateUI(currentUser);
  }
  
  @Override
  public void onBackPressed() {
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      if (drawer.isDrawerOpen(GravityCompat.START)) {
          drawer.closeDrawer(GravityCompat.START);
      } else {
          super.onBackPressed();
      }
  }
  
  @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;
  }
  
  @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.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      // Handle navigation view item clicks here.
      int id = item.getItemId();
  
      if (id == R.id.nav_home) {
          Intent intent = new Intent(this,MainActivity.class);
          startActivity(intent);
  
      } else if (id == R.id.nav_new_ad) {
          Intent intent = new Intent(this,NewAdActivity.class);
          startActivity(intent);
  
      } else if (id == R.id.nav_log_in) {
          Intent intent = new Intent(this,LogInActivity.class);
          startActivity(intent);
  
      } else if (id == R.id.nav_search) {
  
      } else if (id == R.id.nav_new_account) {
          Intent intent = new Intent(this,RegisterActivity.class);
          startActivity(intent);
  
      } else if (id == R.id.nav_log_out) {
          mAuth.signOut();
          resetUI();
          Toast.makeText(MainActivity.this, "Izlogovani ste", Toast.LENGTH_SHORT).show();
  
      } else if (id == R.id.nav_about_us) {
          Intent intent = new Intent(this,AboutUsActivity.class);
          startActivity(intent);
  
      } else if (id == R.id.nav_share) {
  
      } else if (id == R.id.nav_follow_us) {
  
      } else if (id == R.id.nav_contact) {
          Intent intent = new Intent(this,ContactActivity.class);
          startActivity(intent);
  
      }
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  }
  
  private void resetUI() {
  
      navLogIn.setVisible(true);
      navNewAcc.setVisible(true);
      navLogOut.setVisible(false);
  
  }
  
  private void updateUI(FirebaseUser currentUser) {
      // TODO
  
      navLogIn.setVisible(false);
      navNewAcc.setVisible(false);
      navLogOut.setVisible(true);
  
      Toast.makeText(MainActivity.this, currentUser.getEmail().toString(), Toast.LENGTH_SHORT).show();
  
  }
  }
  </code></pre>
  
  <p><strong>I get this error:</strong></p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke interface method
    'android.view.MenuItem android.view.MenuItem.setVisible(boolean)' on a
    null object reference</p>
  </blockquote>
  
  <p>main.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
  &lt;item
      android:id="@+id/action_settings"
      android:orderInCategory="100"
      android:title="@string/action_settings"
      android:visible="false"
      app:showAsAction="never"&gt;&lt;/item&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>activity_main_drawer.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      tools:showIn="nav_view"&gt;
  
      &lt;group&gt;
          &lt;item
              android:id="@+id/nav_home"
              android:title="Početna" /&gt;
          &lt;item
              android:id="@+id/nav_new_ad"
              android:title="Postavi Oglas" /&gt;
          &lt;item
              android:id="@+id/nav_log_in"
              android:title="Prijava" /&gt;
          &lt;item
              android:id="@+id/nav_search"
              android:title="Pretraga"
              android:visible="false" /&gt;
          &lt;item
              android:id="@+id/nav_new_account"
              android:title="Kreiraj nalog" /&gt;
          &lt;item
              android:visible="false"
              android:id="@+id/nav_log_out"
              android:title="Izlogujte se" /&gt;
      &lt;/group&gt;
  
      &lt;item android:title="Komunikacija"&gt;
          &lt;menu&gt;
              &lt;item
                  android:id="@+id/nav_about_us"
                  android:title="O Nama" /&gt;
              &lt;item
                  android:id="@+id/nav_share"
                  android:title="Podeli"
                  android:visible="false" /&gt;
              &lt;item
                  android:id="@+id/nav_follow_us"
                  android:title="Pratite nas"
                  android:visible="false" /&gt;
              &lt;item
                  android:id="@+id/nav_contact"
                  android:title="Kontakt" /&gt;
          &lt;/menu&gt;
      &lt;/item&gt;
  
  &lt;/menu&gt;
  </code></pre>