List of usage examples for android.view MenuItem SHOW_AS_ACTION_ALWAYS
int SHOW_AS_ACTION_ALWAYS
To view the source code for android.view MenuItem SHOW_AS_ACTION_ALWAYS.
Click Source Link
From source file:com.miz.mizuu.fragments.MovieDetailsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.movie_details, menu); // If this is a tablet, we have more room to display icons if (MizLib.isTablet(mContext)) { menu.findItem(R.id.movie_fav).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.findItem(R.id.watch_list).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }/*from ww w. j av a2s . co m*/ // Favourite menu.findItem(R.id.movie_fav) .setIcon(mMovie.isFavourite() ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp) .setTitle(mMovie.isFavourite() ? R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); // Watchlist menu.findItem(R.id.watch_list) .setIcon(mMovie.toWatch() ? R.drawable.ic_video_collection_white_24dp : R.drawable.ic_queue_white_24dp) .setTitle(mMovie.toWatch() ? R.string.removeFromWatchlist : R.string.watchLater); // Watched / unwatched menu.findItem(R.id.watched) .setTitle(mMovie.hasWatched() ? R.string.stringMarkAsUnwatched : R.string.stringMarkAsWatched); // Only allow the user to browse artwork if it's a valid TMDb movie menu.findItem(R.id.change_cover).setVisible(MizLib.isValidTmdbId(mMovie.getTmdbId())); }
From source file:org.transdroid.core.gui.TorrentsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); // No connection yet; hide all menu options except settings if (currentConnection == null) { torrentsToolbar.setNavigationIcon(null); if (selectionToolbar != null) selectionToolbar.setVisibility(View.GONE); addmenuButton.setVisibility(View.GONE); actionsToolbar.setVisibility(View.GONE); if (filtersList != null) filtersList.setVisibility(View.GONE); filterSearch.setVisibility(View.GONE); torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_settings) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(true); actionsToolbar.getMenu().findItem(R.id.action_enableturtle).setVisible(false); actionsToolbar.getMenu().findItem(R.id.action_disableturtle).setVisible(false); actionsToolbar.getMenu().findItem(R.id.action_refresh).setVisible(false); actionsToolbar.getMenu().findItem(R.id.action_sort).setVisible(false); if (fragmentTorrents != null) { fragmentTorrents.updateConnectionStatus(false, null); }/*from w w w . ja v a2s. com*/ return true; } // There is a connection (read: settings to some server known) if (drawerToggle != null) torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer); if (selectionToolbar != null) selectionToolbar.setVisibility(View.VISIBLE); addmenuButton.setVisibility(View.VISIBLE); actionsToolbar.setVisibility(View.VISIBLE); if (filtersList != null) filtersList.setVisibility(View.VISIBLE); filterSearch.setVisibility(View.VISIBLE); boolean addByFile = Daemon.supportsAddByFile(currentConnection.getType()); addmenuFileButton.setVisibility(addByFile ? View.VISIBLE : View.GONE); // Primary toolbar menu torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(navigationHelper.enableSearchUi()); torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(navigationHelper.enableRssUi()); torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(false); // Secondary toolbar menu boolean hasAltMode = Daemon.supportsSetAlternativeMode(currentConnection.getType()); actionsToolbar.getMenu().findItem(R.id.action_enableturtle).setVisible(hasAltMode && !turtleModeEnabled); actionsToolbar.getMenu().findItem(R.id.action_disableturtle).setVisible(hasAltMode && turtleModeEnabled); actionsToolbar.getMenu().findItem(R.id.action_refresh).setVisible(true); actionsToolbar.getMenu().findItem(R.id.action_sort).setVisible(true); actionsToolbar.getMenu().findItem(R.id.action_sort_added) .setVisible(Daemon.supportsDateAdded(currentConnection.getType())); if (fragmentTorrents != null) { fragmentTorrents.updateConnectionStatus(true, currentConnection.getType()); } return true; }
From source file:de.badaix.snapcast.MainActivity.java
public void updateMenuItems(final boolean connected) { this.runOnUiThread(new Runnable() { @Override//from ww w . ja v a 2 s. c om public void run() { if (connected) { if (miSettings != null) miSettings.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (miStartStop != null) miStartStop.setVisible(true); // if (miRefresh != null) // miRefresh.setVisible(true); } else { if (miSettings != null) miSettings.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); if (miStartStop != null) miStartStop.setVisible(false); // if (miRefresh != null) // miRefresh.setVisible(false); } } }); }
From source file:com.miz.mizuu.fragments.TvShowDetailsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.tv_show_details, menu); // If this is a tablet, we have more room to display icons if (MizLib.isTablet(mContext)) menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // Favourite/*w w w . j a va 2s . c o m*/ menu.findItem(R.id.show_fav) .setIcon(thisShow.isFavorite() ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp) .setTitle(thisShow.isFavorite() ? R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // ??/*w ww. j a v a 2s . c o m*/ MenuItem actionItem = menu.add(Menu.NONE, MENU_ID.SETTING.ordinal(), MENU_ID.SETTING.ordinal(), this.getString(R.string.menu_title_setting)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.SETTING.getDrawableResId()); // Twitter? actionItem = menu.add(Menu.NONE, MENU_ID.TWITTER.ordinal(), MENU_ID.TWITTER.ordinal(), this.getString(R.string.menu_title_share)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.TWITTER.getDrawableResId()); // Facebook actionItem = menu.add(Menu.NONE, MENU_ID.FACEBOOK.ordinal(), MENU_ID.FACEBOOK.ordinal(), this.getString(R.string.menu_title_facebook)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.FACEBOOK.getDrawableResId()); if (enableNewFunction) { // HISTORY actionItem = menu.add(Menu.NONE, MENU_ID.HISTORY.ordinal(), MENU_ID.HISTORY.ordinal(), this.getString(R.string.menu_title_history)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); actionItem.setIcon(MENU_ID.HISTORY.getDrawableResId()); } // LINE actionItem = menu.add(Menu.NONE, MENU_ID.LINE.ordinal(), MENU_ID.LINE.ordinal(), this.getString(R.string.menu_title_line)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.LINE.getDrawableResId()); // FEEDBACK actionItem = menu.add(Menu.NONE, MENU_ID.FEEDBACK.ordinal(), MENU_ID.FEEDBACK.ordinal(), this.getString(R.string.menu_title_feedback)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); actionItem.setIcon(MENU_ID.FEEDBACK.getDrawableResId()); // LICENSE actionItem = menu.add(Menu.NONE, MENU_ID.LICENSE.ordinal(), MENU_ID.LICENSE.ordinal(), this.getString(R.string.menu_title_license)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); actionItem.setIcon(MENU_ID.LICENSE.getDrawableResId()); return true; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE, getString(R.string.order_call_taxi_page_title)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//from w w w. ja v a 2 s . com Utility driver = new Utility(getActivity()); if (isShowOneKey && driver.getAllDriverAccountInfo().isEmpty()) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (sessionState == SESSION_ERROR && getCurrentSession() == null) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_account_reload, Menu.FIRST, R.string.retry_account_loading); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS); }//from w ww . jav a2 s . c o m return super.onCreateOptionsMenu(menu); }
From source file:com.nextgis.ngm_clink_monitoring.activities.MainActivity.java
@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_main, menu); switch (mViewState) { case VIEW_STATE_1ST_SYNC: menu.findItem(R.id.menu_map).setEnabled(false); case VIEW_STATE_LOGIN: menu.findItem(R.id.menu_sync).setEnabled(false); break;/*from w ww.j a va 2s . c o m*/ case VIEW_STATE_OBJECTS: String tag = getMainFragmentTag(); if (TextUtils.isEmpty(tag)) { tag = ""; } switch (tag) { case FoclConstants.FRAGMENT_SYNC_LOGIN: case FoclConstants.FRAGMENT_PERFORM_1ST_SYNC: case FoclConstants.FRAGMENT_LINE_LIST: case FoclConstants.FRAGMENT_OBJECT_LIST: case FoclConstants.FRAGMENT_OBJECT_STATUS: case FoclConstants.FRAGMENT_MAP: default: break; case FoclConstants.FRAGMENT_OBJECT_TYPES: menu.findItem(R.id.menu_line_status).setVisible(true); break; case FoclConstants.FRAGMENT_CREATE_OBJECT: MenuItemCompat.setShowAsAction(menu.findItem(R.id.menu_map), MenuItem.SHOW_AS_ACTION_ALWAYS); break; } break; case VIEW_STATE_MAP: menu.findItem(R.id.menu_map).setVisible(false); menu.findItem(R.id.menu_location).setVisible(true); menu.findItem(R.id.menu_refresh_map).setVisible(true); break; } if (mIsSyncing) { menu.findItem(R.id.menu_sync).setEnabled(false); } return true; }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void parseMenu(XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); String tagName;//from ww w . ja v a 2 s .c om 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) alwaysShowingMenu.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(); } }