Java Code Examples for android.view.MenuItem#SHOW_AS_ACTION_NEVER

The following examples show how to use android.view.MenuItem#SHOW_AS_ACTION_NEVER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactToolbar.java    From react-native-GPay with MIT License 6 votes vote down vote up
void setActions(@Nullable ReadableArray actions) {
  Menu menu = getMenu();
  menu.clear();
  mActionsHolder.clear();
  if (actions != null) {
    for (int i = 0; i < actions.size(); i++) {
      ReadableMap action = actions.getMap(i);

      MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString(PROP_ACTION_TITLE));

      if (action.hasKey(PROP_ACTION_ICON)) {
        setMenuItemIcon(item, action.getMap(PROP_ACTION_ICON));
      }

      int showAsAction = action.hasKey(PROP_ACTION_SHOW)
          ? action.getInt(PROP_ACTION_SHOW)
          : MenuItem.SHOW_AS_ACTION_NEVER;
      if (action.hasKey(PROP_ACTION_SHOW_WITH_TEXT) &&
          action.getBoolean(PROP_ACTION_SHOW_WITH_TEXT)) {
        showAsAction = showAsAction | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
      }
      item.setShowAsAction(showAsAction);
    }
  }
}
 
Example 2
Source File: Button.java    From react-native-navigation with MIT License 6 votes vote down vote up
private static Number parseShowAsAction(JSONObject json) {
    final Text showAsAction = TextParser.parse(json, "showAsAction");
    if (!showAsAction.hasValue()) {
        return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    switch (showAsAction.get()) {
        case "always":
            return new Number(MenuItem.SHOW_AS_ACTION_ALWAYS);
        case "never":
            return new Number(MenuItem.SHOW_AS_ACTION_NEVER);
        case "withText":
            return new Number(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        case "ifRoom":
        default:
            return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}
 
Example 3
Source File: ActionMenuConfigurator.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private static int getShowAsAction(MenuItem menuItem) {
	try {
		return SHOW_AS_ACTION_FIELD.getInt(menuItem);
	} catch (Exception e) {
		return MenuItem.SHOW_AS_ACTION_NEVER;
	}
}