title: Android Change Navigation Drawer Menu Items Text programmatically
body: <p>I have the new Navigation Drawer in my app and I want to change the navigation view menu items title text dynamically from code. I have watched many posts but I can't figure out, how can I do this. How can I achieve this correctly?</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  
  setContentView(R.layout.activity_main);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  
  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                  .setAction("Action", null).show();
      }
  });
  
  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.setDrawerListener(toggle);
  toggle.syncState();
  
  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
  
  }
  </code></pre>
  
  <p><strong>activity_main_drawer.xml</strong></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_camara" android:icon="@android:drawable/ic_menu_camera"
          android:title="Import" /&gt;
      &lt;item android:id="@+id/nav_gallery" android:icon="@android:drawable/ic_menu_gallery"
          android:title="Gallery" /&gt;
      &lt;item android:id="@+id/nav_slideshow" android:icon="@android:drawable/ic_menu_slideshow"
          android:title="Slideshow" /&gt;
      &lt;item android:id="@+id/nav_manage" android:icon="@android:drawable/ic_menu_manage"
          android:title="Tools" /&gt;
  &lt;/group&gt;
  
  &lt;item android:title="Communicate"&gt;
      &lt;menu&gt;
          &lt;item android:id="@+id/nav_share" android:icon="@android:drawable/ic_menu_share"
              android:title="Share" /&gt;
          &lt;item android:id="@+id/nav_send" android:icon="@android:drawable/ic_menu_send"
              android:title="Send" /&gt;
      &lt;/menu&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p></p>