Java Code Examples for android.view.MenuItem#SHOW_AS_ACTION_ALWAYS
The following examples show how to use
android.view.MenuItem#SHOW_AS_ACTION_ALWAYS .
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: Button.java From react-native-navigation with MIT License | 6 votes |
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 2
Source File: ButtonPresenterTest.java From react-native-navigation with MIT License | 5 votes |
private Button createButton() { Button b = new Button(); b.id = "btn1"; b.text = new Text("button"); b.color = new Colour(Color.RED); b.showAsAction = new Number(MenuItem.SHOW_AS_ACTION_ALWAYS); return b; }
Example 3
Source File: TopBarButtonControllerTest.java From react-native-navigation with MIT License | 5 votes |
private void setIconButton(boolean enabled) { button.id = "btn1"; button.icon = new Text("someIcon"); button.color = new Colour(Color.RED); button.component.name = new NullText(); button.component.componentId = new NullText(); button.enabled = new Bool(enabled); button.showAsAction = new Number(MenuItem.SHOW_AS_ACTION_ALWAYS); }
Example 4
Source File: ListUnit.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { gridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); gridView.clearChoices(); mode.setTitle(instance.context.getString(R.string.text_selected_format, 0)); int selectAllResId = ResourceUtils.getSystemSelectionIcon(instance.context, "actionModeSelectAllDrawable", "ic_menu_selectall_holo_dark"); int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT; ActionIconSet set = new ActionIconSet(instance.context); menu.add(0, ACTION_MENU_SELECT_ALL, 0, R.string.action_select_all) .setIcon(selectAllResId).setShowAsAction(flags); menu.add(0, ACTION_MENU_DOWNLOAD_FILES, 0, R.string.action_download_files) .setIcon(set.getId(R.attr.actionDownload)).setShowAsAction(flags); return true; }
Example 5
Source File: PostsPage.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { PageHolder pageHolder = getPageHolder(); ChanConfiguration configuration = getChanConfiguration(); getAdapter().setSelectionModeEnabled(true); mode.setTitle(getString(R.string.text_selected_format, 0)); int pasteResId = ResourceUtils.getSystemSelectionIcon(getActivity(), "actionModePasteDrawable", "ic_menu_paste_holo_dark"); int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT; ChanConfiguration.Board board = configuration.safe().obtainBoard(pageHolder.boardName); menu.add(0, ACTION_MENU_MAKE_THREADSHOT, 0, R.string.action_make_threadshot) .setIcon(obtainIcon(R.attr.actionMakeThreadshot)).setShowAsAction(flags); if (replyable != null) { menu.add(0, ACTION_MENU_REPLY, 0, R.string.action_reply).setIcon(pasteResId).setShowAsAction(flags); } if (board.allowDeleting) { ChanConfiguration.Deleting deleting = configuration.safe().obtainDeleting(pageHolder.boardName); if (deleting != null && deleting.multiplePosts) { menu.add(0, ACTION_MENU_DELETE_POSTS, 0, R.string.action_delete) .setIcon(obtainIcon(R.attr.actionDelete)).setShowAsAction(flags); } } if (board.allowReporting) { ChanConfiguration.Reporting reporting = configuration.safe().obtainReporting(pageHolder.boardName); if (reporting != null && reporting.multiplePosts) { menu.add(0, ACTION_MENU_SEND_REPORT, 0, R.string.action_report) .setIcon(obtainIcon(R.attr.actionReport)).setShowAsAction(flags); } } return true; }
Example 6
Source File: CommentTextView.java From Dashchan with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.M) @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { currentActionMode = mode; currentActionModeMenu = menu; setSelectionMode(true); int pasteResId = ResourceUtils.getSystemSelectionIcon(getContext(), "actionModePasteDrawable", "ic_menu_paste_holo_dark"); ActionIconSet set = new ActionIconSet(getContext()); int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT; if (C.API_MARSHMALLOW && mode.getType() == ActionMode.TYPE_FLOATING) { int order = 1; // Only "cut" menu item uses this order which doesn't present in non-editable TextView if (replyable != null) { menu.add(0, android.R.id.button1, order, R.string.action_quote) .setIcon(pasteResId).setShowAsAction(flags); } menu.add(0, android.R.id.button2, order, R.string.action_browser) .setIcon(set.getId(R.attr.actionForward)).setShowAsAction(flags); } else { if (replyable != null) { menu.add(0, android.R.id.button1, 0, R.string.action_quote).setIcon(pasteResId) .setShowAsAction(flags); } menu.add(0, android.R.id.button2, 0, R.string.action_browser).setIcon(set.getId(R.attr.actionForward)) .setShowAsAction(flags); } // Stop selection fixation after creating action mode restoreSelectionRunnable = null; return true; }
Example 7
Source File: FloatingSearchView.java From FloatingSearchView with Apache License 2.0 | 4 votes |
private void parseMenu(XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); String tagName; boolean lookingForEndOfUnknownTag = false; String unknownTagName = null; // This loop will skip to the menu start tag do { if (eventType == XmlPullParser.START_TAG) { tagName = parser.getName(); if (tagName.equals("menu")) { // Go to next tag eventType = parser.next(); break; } throw new RuntimeException("Expecting menu, got " + tagName); } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); boolean reachedEndOfMenu = false; while (!reachedEndOfMenu) { switch (eventType) { case XmlPullParser.START_TAG: if (lookingForEndOfUnknownTag) { break; } tagName = parser.getName(); if (tagName.equals("item")) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MenuItem); int itemShowAsAction = a.getInt(R.styleable.MenuItem_showAsAction, -1); if((itemShowAsAction & MenuItem.SHOW_AS_ACTION_ALWAYS) != 0) { int itemId = a.getResourceId(R.styleable.MenuItem_android_id, NO_ID); if(itemId != NO_ID) mAlwaysShowingMenu.add(itemId); } a.recycle(); } else { lookingForEndOfUnknownTag = true; unknownTagName = tagName; } break; case XmlPullParser.END_TAG: tagName = parser.getName(); if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { lookingForEndOfUnknownTag = false; unknownTagName = null; } else if (tagName.equals("menu")) { reachedEndOfMenu = true; } break; case XmlPullParser.END_DOCUMENT: throw new RuntimeException("Unexpected end of document"); } eventType = parser.next(); } }
Example 8
Source File: FloatingSearchView.java From FloatingSearchView with Apache License 2.0 | 4 votes |
private void parseMenu(XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); String tagName; boolean lookingForEndOfUnknownTag = false; String unknownTagName = null; // This loop will skip to the menu start tag do { if (eventType == XmlPullParser.START_TAG) { tagName = parser.getName(); if (tagName.equals("menu")) { // Go to next tag eventType = parser.next(); break; } throw new RuntimeException("Expecting menu, got " + tagName); } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); boolean reachedEndOfMenu = false; while (!reachedEndOfMenu) { switch (eventType) { case XmlPullParser.START_TAG: if (lookingForEndOfUnknownTag) { break; } tagName = parser.getName(); if (tagName.equals("item")) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MenuItem); int itemShowAsAction = a.getInt(R.styleable.MenuItem_showAsAction, -1); if((itemShowAsAction & MenuItem.SHOW_AS_ACTION_ALWAYS) != 0) { int itemId = a.getResourceId(R.styleable.MenuItem_android_id, NO_ID); if(itemId != NO_ID) mAlwaysShowingMenu.add(itemId); } a.recycle(); } else { lookingForEndOfUnknownTag = true; unknownTagName = tagName; } break; case XmlPullParser.END_TAG: tagName = parser.getName(); if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { lookingForEndOfUnknownTag = false; unknownTagName = null; } else if (tagName.equals("menu")) { reachedEndOfMenu = true; } break; case XmlPullParser.END_DOCUMENT: throw new RuntimeException("Unexpected end of document"); } eventType = parser.next(); } }