title: Android, how to set navigation view group visibility on runtime?
body: <p>I am confuse how to set navigation view group visibility on runtime. I want to create a login function on navigation drawer. When users tapped the login item there, the application do <code>startActivityForResult()</code>. Here is my menu xml code.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
          &lt;group android:checkableBehavior="single"&gt;
              &lt;item android:id="@+id/nav_featured" android:icon="@drawable/ic_notifications_on_24dp"
                  android:title="Featured" /&gt;
              &lt;item android:id="@+id/nav_top_rated" android:icon="@drawable/ic_star_rate_24dp"
                  android:title="Top Rated" android:checked="true"/&gt;
              &lt;item android:id="@+id/nav_most_visited" android:icon="@drawable/ic_group_24dp"
                  android:title="Most Visited" /&gt;
              &lt;item android:id="@+id/nav_arround_you" android:icon="@drawable/ic_place_24dp"
                  android:title="Arround You" /&gt;
          &lt;/group&gt;
  
          &lt;group android:id="@+id/public_items"&gt;
              &lt;item android:title="My Account"&gt;
                  &lt;menu&gt;
                      &lt;item android:id="@+id/nav_login" android:icon="@drawable/ic_person_24dp"
                          android:title="Login" /&gt;
                  &lt;/menu&gt;
              &lt;/item&gt;
          &lt;/group&gt;
  
         &lt;group android:id="@+id/login_items" android:visible="false"&gt;
              &lt;item android:title="My Account"&gt;
                  &lt;menu&gt;
                      &lt;item android:id="@+id/nav_search" android:icon="@drawable/ic_directions_bike_24dp"
                          android:title="Search"/&gt;
                      &lt;item android:id="@+id/nav_my_bookings" android:icon="@drawable/ic_event_available_24dp"
                          android:title="My Bookings"/&gt;
                      &lt;item android:id="@+id/nav_profile" android:icon="@drawable/ic_tag_faces_24dp"
                          android:title="My Profile"/&gt;
                      &lt;item android:id="@+id/nav_logout" android:icon="@drawable/ic_power_settings_new_black_24dp"
                          android:title="Logout"/&gt;
                  &lt;/menu&gt;
              &lt;/item&gt;
          &lt;/group&gt;
      &lt;/menu&gt;
  </code></pre>
  
  <p>And here is my java code.</p>
  
  <pre><code>    @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (resultCode == RESULT_OK) {
              if (requestCode == REQUEST_CODE_FOR_LOGIN) {
                  navigationView.getMenu().setGroupVisible(R.id.login_items, true);
              }
          }
      }
  </code></pre>
  
  <p>And nothing happened.</p>