I am trying to modify the title of menu item on google glass dynamically. As there is no hardware menu button and My activity is themed NoActionBarFullScreen, creating and initializing the Menu menu item in onCreateOptionsMenu always give null value because onCreateOptionsMenu never called. So how to do that ?
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.gatt_services, menu);
if (!init) {
// I want to do this outside of this function also
menu.findItem(R.id.menu_connect).setTitle("Connect"); }
else {
menu.findItem(R.id.menu_connect).setTitle("Disconnect");
}
// so I initialized this variable here
this.menu = menu; // but this is always null
return true;
}
MenuItem connetItem = menu.findItem(R.id.menu_connect); // App crashes
So how do i access this menu item and change its title?