當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setShowAsAction方法代碼示例

本文整理匯總了Java中android.view.MenuItem.setShowAsAction方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setShowAsAction方法的具體用法?Java MenuItem.setShowAsAction怎麽用?Java MenuItem.setShowAsAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.setShowAsAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if(loaderId == DELETED_LOADER_ID){
        inflater.inflate(R.menu.menu_fragment_bin, menu);
    }

    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView = new SearchView(myActivity);
    searchView.setMaxWidth(Integer.MAX_VALUE);

    // Set searchbox text to white
    EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
    searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));

    searchView.setOnQueryTextListener(this);
    item.setActionView(searchView);
    super.onCreateOptionsMenu(menu, inflater);

}
 
開發者ID:danlls,項目名稱:Todule-android,代碼行數:25,代碼來源:ToduleListFragment.java

示例2: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    MenuItem about = menu.findItem(R.id.menu_about);
    switch (remoteConfig.getExperimentVariant(IRemoteConfig.EXPERIMENT_ABOUT_MENU)) {
        case VARIANT_A:
            about.setIcon(R.drawable.ic_info_sign);
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            break;
        case VARIANT_B:
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            break;
        default:
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    return true;
}
 
開發者ID:riteshakya037,項目名稱:Wallpapers-Android-Clean-Architecture,代碼行數:20,代碼來源:OnBoardingActivity.java

示例3: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
        final Locale systemLocale = getResources().getConfiguration().locale;
        if (!TextUtils.isEmpty(mLocale) && !mLocale.equals(systemLocale.toString())) {
            // Hide the add button for ICS because it doesn't support specifying a locale
            // for an entry. This new "locale"-aware API has been added in conjunction
            // with the shortcut API.
            return;
        }
    }
    MenuItem actionItem =
            menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
            .setIcon(R.drawable.ic_menu_add);
    actionItem.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:18,代碼來源:UserDictionarySettings.java

示例4: add

import android.view.MenuItem; //導入方法依賴的package包/類
public MenuItem add(Drawable icon, BadgeStyle style, int badgeCount, ActionItemBadge.ActionItemBadgeListener listener) {
    MenuItem item;
    if (groupId != null && itemId != null && order != null) {
        item = menu.add(groupId, itemId, order, title);
    } else {
        item = menu.add(title);
    }

    if (showAsAction != null) {
        item.setShowAsAction(showAsAction);
    }

    item.setActionView(style.getLayout());
    ActionItemBadge.update(activity, item, icon, style, badgeCount, listener);
    return item;
}
 
開發者ID:OmarAliSaid,項目名稱:android-paypal-example,代碼行數:17,代碼來源:ActionItemBadgeAdder.java

示例5: setActions

import android.view.MenuItem; //導入方法依賴的package包/類
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);
    }
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:26,代碼來源:ReactToolbar.java

示例6: onCreateActionMode

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
    pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    pasteMenu.setEnabled(fileClipboard.canPaste());

    renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
    renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    shareMenu = menu.add(0, R.id.share, 0, R.string.share);
    shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    shareActionProvider = new ShareActionProvider(context);
    shareActionProvider.setOnShareTargetSelectedListener(this);
    MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);

    menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:23,代碼來源:FileExplorerAction.java

示例7: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem item =
            menu.add(Menu.NONE, R.id.action_chat_sdk_edit, 13, getString(R.string.action_edit));
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    item.setIcon(R.drawable.ic_edit);
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:10,代碼來源:ChatcatProfileFragment.java

示例8: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    if (!enableActionBarItems)
        return;

    MenuItem item =
            menu.add(Menu.NONE, R.id.action_chat_sdk_logout, 12, "Logout");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    item.setIcon(R.drawable.ic_cancel);
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:13,代碼來源:ChatSDKAbstractProfileFragment.java

示例9: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem item =
            menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, getString(R.string.public_thread_fragment_add_item_text));
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    item.setIcon(R.drawable.ic_plus);
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:9,代碼來源:ChatSDKThreadsFragment.java

示例10: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    if (!inflateMenuItems)
        return super.onCreateOptionsMenu(menu);

    // Adding the add user option only if group chat is enabled.
    if (BDefines.Options.GroupEnabled)
    {
        MenuItem item =
                menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, getString(R.string.chat_activity_show_users_item_text));
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        item.setIcon(R.drawable.ic_plus);
    }

    if (BDefines.Options.ThreadDetailsEnabled)
    {

        MenuItem itemThreadUsers =
            menu.add(Menu.NONE, R.id.action_chat_sdk_thread_details, 10, getString(R.string.chat_activity_show_thread_details));
        
        itemThreadUsers.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        itemThreadUsers.setIcon(android.R.drawable.ic_menu_info_details);
    }
    
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:28,代碼來源:ChatSDKAbstractChatActivity.java

示例11: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu (Menu menu, MenuInflater inflater) {
    MenuItem itemOk = menu.add(0, 0, 0, R.string.apply);
    Drawable iconOk = ContextCompat.getDrawable(getActivity(),
            R.drawable.ic_check_black_24dp);
    DrawableCompat.setTint(iconOk, Utils.getColorAttr(getContext(), R.attr.colorAccent));
    itemOk.setIcon(iconOk);
    itemOk.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:10,代碼來源:ManagePermissionsActivity.java

示例12: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    final MenuItem actionItemAdd = menu.add(0, OPTIONS_MENU_ADD, 0,
            R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
    actionItemAdd.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    final MenuItem actionItemDelete = menu.add(0, OPTIONS_MENU_DELETE, 0,
            R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
    actionItemDelete.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:12,代碼來源:UserDictionaryAddWordFragment.java

示例13: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!inflateMenuItems)
        return;

    super.onCreateOptionsMenu(menu, inflater);
    MenuItem item =
            menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, "Add Conversation");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    item.setIcon(R.drawable.ic_plus);
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:12,代碼來源:ChatSDKAbstractConversationsFragment.java

示例14: onPrepareOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (menu.size() == 1) {
        MenuItem item = menu.getItem(0);
        if (item.getIcon() != null) item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:9,代碼來源:Preferences.java

示例15: onCreateOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	super.onCreateOptionsMenu(menu, inflater);
	if (mBrowserAdapter != null && !mBrowserAdapter.isEmpty() && mSortModeSubmenu!=null) {
		// Add the "sort mode" item
		MenuItem sortMenuItem = menu.add(Browser.MENU_VIEW_MODE_GROUP, Browser.MENU_VIEW_MODE, Menu.NONE, R.string.sort_mode);
		sortMenuItem.setIcon(R.drawable.ic_menu_sort);
		sortMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
		mSortModeSubmenu.attachMenuItem(sortMenuItem);

		mSortModeSubmenu.clear();
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_name_asc,              MENU_ITEM_SORT+MENU_ITEM_NAME    +MENU_ITEM_ASC);
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_name_desc,             MENU_ITEM_SORT+MENU_ITEM_NAME    +MENU_ITEM_DESC);
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_date_premiered_desc,   MENU_ITEM_SORT+MENU_ITEM_YEAR    +MENU_ITEM_DESC);
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_date_premiered_asc,    MENU_ITEM_SORT+MENU_ITEM_YEAR    +MENU_ITEM_ASC);
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_rating_asc,            MENU_ITEM_SORT+MENU_ITEM_RATING  +MENU_ITEM_DESC);
		mSortModeSubmenu.addSubmenuItem(0, R.string.sort_by_recently_added_episode_desc, MENU_ITEM_SORT+MENU_ITEM_ADDED+MENU_ITEM_DESC);

		// Init with the current value
		int initId = sortorder2itemid(mSortOrder);
		if (initId==-1) { // not found
			mSortModeSubmenu.selectSubmenuItem(0);
		}
		else {
			int position = mSortModeSubmenu.getPosition(initId);
			if (position<0) { // not found
			    position=0;
			}
			mSortModeSubmenu.selectSubmenuItem(position);
		}
	}
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:32,代碼來源:BrowserAllTvShows.java


注:本文中的android.view.MenuItem.setShowAsAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。