title: Working with NavigationView items within a Fragment
body: <p>I'm trying to execute the next code inside the onCreateView method of my Fragment:</p>
  
  <pre><code> if (displayedPalabra!=null){
          setCardAttributes(displayedPalabra);
          NavigationView navigationView = (NavigationView) layout.findViewById(R.id.nav_view);
          navigationView.getMenu().getItem(0).setChecked(true);
      }
  </code></pre>
  
  <p>But gives me the next error when executing:                                                               </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method
    'android.view.Menu
    android.support.design.widget.NavigationView.getMenu()' on a null
    object reference</p>
  </blockquote>
  
  <p>My question is: Is the layout from the Fragment not being able to access the NavigationView From the MainActivity and thus retrieving a null value? Do I have to somehow access it some other way? The code should be self-explanatory, im just trying to set this Fragment's item as checked at the NavigationView Menu of my app... usually I do it from the MainActivity to put the default one but this Fragment is called from another fragment this time...</p>