@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.sort, menu); SubMenu subMenu = menu.findItem(R.id.SORT_COMMAND).getSubMenu(); subMenu.findItem(R.id.SORT_AMOUNT_COMMAND).setVisible(true); subMenu.findItem(R.id.SORT_NEXT_INSTANCE_COMMAND).setVisible(true); }
// region Menu @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_uart, menu); // Mqtt mMqttMenuItem = menu.findItem(R.id.action_mqttsettings); mMqttMenuItemAnimationHandler = new Handler(); mMqttMenuItemAnimationRunnable.run(); // DisplayMode MenuItem displayModeMenuItem = menu.findItem(R.id.action_displaymode); displayModeMenuItem.setTitle( String.format( getString(R.string.uart_action_displaymode_format), getString( mIsTimestampDisplayMode ? R.string.uart_displaymode_timestamp : R.string.uart_displaymode_text))); SubMenu displayModeSubMenu = displayModeMenuItem.getSubMenu(); if (mIsTimestampDisplayMode) { MenuItem displayModeTimestampMenuItem = displayModeSubMenu.findItem(R.id.action_displaymode_timestamp); displayModeTimestampMenuItem.setChecked(true); } else { MenuItem displayModeTextMenuItem = displayModeSubMenu.findItem(R.id.action_displaymode_text); displayModeTextMenuItem.setChecked(true); } // DataMode MenuItem dataModeMenuItem = menu.findItem(R.id.action_datamode); dataModeMenuItem.setTitle( String.format( getString(R.string.uart_action_datamode_format), getString( mShowDataInHexFormat ? R.string.uart_format_hexadecimal : R.string.uart_format_ascii))); SubMenu dataModeSubMenu = dataModeMenuItem.getSubMenu(); if (mShowDataInHexFormat) { MenuItem dataModeHexMenuItem = dataModeSubMenu.findItem(R.id.action_datamode_hex); dataModeHexMenuItem.setChecked(true); } else { MenuItem dataModeAsciiMenuItem = dataModeSubMenu.findItem(R.id.action_datamode_ascii); dataModeAsciiMenuItem.setChecked(true); } // Echo MenuItem echoMenuItem = menu.findItem(R.id.action_echo); echoMenuItem.setTitle(R.string.uart_action_echo); echoMenuItem.setChecked(mIsEchoEnabled); // Eol MenuItem eolMenuItem = menu.findItem(R.id.action_eol); eolMenuItem.setTitle(R.string.uart_action_eol); eolMenuItem.setChecked(mIsEolEnabled); return true; }