当前位置: 首页>>代码示例>>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;未经允许,请勿转载。