title: How to remove item from menu programmatically?
body: <p>I've created bottom bar navigation with menu. I want to remove menu items by checking some conditions, so i want it remove using java code. I have tried it using <code>onCreateOptionsMenu()</code>, but somehow it did not work. I don't know what am i doing wrong, a little help would be appreciated.</p>
  
  <pre><code>     @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.member_activities);        
              BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomViewBar);
              BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
              menu = bottomNavigationView.getMenu();
              MenuItem menuItem = menu.getItem(0);
              menuItem.setChecked(true);
  }
    @Override
          public boolean onCreateOptionsMenu(Menu menu) {
              this.menu = menu;
              menu.removeItem(R.id.district_tab);
              return true;
          }
  </code></pre>
  
  <p>bottom_navigation_menu.xml:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;item
      android:id="@+id/member_tab"
      android:icon="@drawable/ic_person_outline"
      android:title="Member"/&gt;
  &lt;item
      android:id="@+id/club_tab"
      android:icon="@drawable/ic_person_outline"
      android:title="Club"/&gt;
  
  &lt;item
      android:id="@+id/district_tab"
      android:icon="@drawable/ic_person_outline"
      android:title="District"/&gt;
  
  &lt;item
      android:id="@+id/ag_tab"
      android:icon="@drawable/ic_person_outline"
      android:title="AG"/&gt;
  
  &lt;item
      android:id="@+id/dg_tab"
      android:icon="@drawable/ic_person_outline"
      android:title="DG"/&gt;
  </code></pre>
  
  <p></p>