本文整理了Java中android.view.MenuItem.setShowAsAction()
方法的一些代码示例,展示了MenuItem.setShowAsAction()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setShowAsAction()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:setShowAsAction
暂无
代码示例来源:origin: ankidroid/Anki-Android
private void setCustomButtons(Menu menu) {
for(int itemId : mCustomButtons.keySet()) {
if(mCustomButtons.get(itemId) != MENU_DISABLED) {
menu.findItem(itemId).setShowAsAction(mCustomButtons.get(itemId));
}
else {
menu.findItem(itemId).setVisible(false);
}
}
}
代码示例来源:origin: alexvasilkov/GestureViews
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (infoTextId != 0) {
MenuItem item = menu.add(Menu.NONE, R.id.menu_info, Menu.NONE, R.string.menu_info);
item.setIcon(R.drawable.ic_info_outline_white_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
return true;
}
代码示例来源:origin: mmin18/RealtimeBlurView
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("Popup").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add("List").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: north2016/T-MVP
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (collapsedMenu != null && !appBarExpanded)
collapsedMenu.add("Add").setIcon(R.drawable.ic_menu_send).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onPrepareOptionsMenu(collapsedMenu);
}
}
代码示例来源:origin: alexvasilkov/GestureViews
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
if (resultView.getVisibility() != View.VISIBLE) {
MenuItem crop = menu.add(Menu.NONE, R.id.menu_crop, 0, R.string.menu_crop);
crop.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
crop.setIcon(R.drawable.ic_check_white_24dp);
}
return true;
}
代码示例来源:origin: termux/termux-app
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
int show = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.copy_text).setShowAsAction(show);
menu.add(Menu.NONE, 2, Menu.NONE, R.string.paste_text).setEnabled(clipboard.hasPrimaryClip()).setShowAsAction(show);
menu.add(Menu.NONE, 3, Menu.NONE, R.string.text_selection_more);
return true;
}
代码示例来源:origin: stackoverflow.com
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
代码示例来源:origin: stackoverflow.com
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE, R.string.restore_defaults);
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
final int restoreIcon = ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_restore_defaults);
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(), restoreIcon));
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem item = menu.add(Menu.NONE, ID, POSITION, TEXT);
item.setIcon(R.drawable.drawable_resource_name);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
代码示例来源:origin: ukanth/afwall
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// Common options: Copy, Export to SD Card, Refresh
menu.add(0, MENU_ADD, 0, getString(R.string.profile_add)).setIcon(R.drawable.plus).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu);
return true;
}
代码示例来源:origin: doggycoder/AndroidOpenGLDemo
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("切换摄像头").setTitle("切换摄像头").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (!inflateMenu)
return;
MenuItem item =
menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, "Add Chat");
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(R.drawable.ic_plus);
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem item = menu.add(Menu.NONE, R.id.action_chat_sdk_save, 12, getString(R.string.action_save));
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(R.drawable.icn_24_save);
return true;
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public boolean onCreateOptionsMenu(Menu menu) {
chatMenuItem = menu.add(Menu.NONE, R.id.action_chat_sdk_chat, 1, getString(R.string.action_chat));
chatMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
chatMenuItem.setIcon(R.drawable.icn_24_chat);
return true;
}
代码示例来源:origin: ukanth/afwall
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Common options: Copy, Export to SD Card, Refresh
SubMenu sub = menu.addSubMenu(0, MENU_TOGGLE, 0, "").setIcon(R.drawable.ic_flow);
sub.add(0, MENU_CLEAR, 0, R.string.clear_log).setIcon(R.drawable.ic_clearlog);
//sub.add(0, MENU_EXPORT_LOG, 0, R.string.export_to_sd).setIcon(R.drawable.exportr);
//populateMenu(sub);
sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
super.onCreateOptionsMenu(menu);
mainMenu = menu;
return true;
}
代码示例来源:origin: ukanth/afwall
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// Common options: Copy, Export to SD Card, Refresh
SubMenu sub = menu.addSubMenu(0, MENU_TOGGLE, 0, "").setIcon(R.drawable.ic_flow);
sub.add(0, MENU_CLEAR, 0, R.string.clear_log).setIcon(R.drawable.ic_clearlog);
sub.add(0, MENU_SWITCH_OLD, 0, R.string.switch_old).setIcon(R.drawable.ic_log);
//populateMenu(sub);
sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
super.onCreateOptionsMenu(menu);
mainMenu = menu;
return true;
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (allowThreadCreation()) {
addMenuItem = menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, getString(R.string.thread_fragment_add_item_text));
addMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
addMenuItem.setIcon(R.drawable.ic_plus);
}
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (!getUser().isMe())
return;
MenuItem item =
menu.add(Menu.NONE, R.id.action_chat_sdk_settings, 12, getString(R.string.action_settings));
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(R.drawable.icn_24_settings);
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public boolean onCreateOptionsMenu(Menu menu) {
updateGallery();
if (!getUser().isMe())
return super.onCreateOptionsMenu(menu);
addMenuItem = menu.add(Menu.NONE, R.id.action_chat_sdk_add, 12, getString(R.string.action_add_picture));
addMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
addMenuItem.setIcon(R.drawable.ic_plus);
addMenuItem.setVisible(shouldShowAddButton(ChatSDK.profilePictures().fromUser(getUser())));
return super.onCreateOptionsMenu(menu);
}
内容来源于网络,如有侵权,请联系作者删除!