本文整理了Java中android.view.MenuItem.setShowAsActionFlags()
方法的一些代码示例,展示了MenuItem.setShowAsActionFlags()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setShowAsActionFlags()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:setShowAsActionFlags
暂无
代码示例来源:origin: robolectric/robolectric
item = item.setShortcut('6', 'z');
assertThat(item).isNotNull();
item = item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
assertThat(item).isNotNull();
item = item.setTitleCondensed("condensed");
代码示例来源:origin: stackoverflow.com
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
MenuItem item = menu.findItem(R.id.your_menu_item);
item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
@Override
public MenuItem setShowAsActionFlags(int actionEnum) {
mNativeItem.setShowAsActionFlags(actionEnum);
return this;
}
代码示例来源:origin: com.willowtreeapps/oak-demos
@Override
public MenuItem setShowAsActionFlags(int actionEnum) {
mNativeItem.setShowAsActionFlags(actionEnum);
return this;
}
代码示例来源:origin: stackoverflow.com
final MenuItem item = menu.findItem(R.id.search);
item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | MenuItem.SHOW_AS_ACTION_ALWAYS);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setMaxWidth(Integer.MAX_VALUE);
代码示例来源:origin: stackoverflow.com
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem menuItem = menu.add("Refresh");
if(this.hardwareButton) {
menuItem.setShowAsActionFlags(android.view.MenuItem.SHOW_AS_ACTION_NEVER);
} else {
menuItem.setIcon(R.drawable.ic_action_refresh);
menuItem.setShowAsActionFlags(android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
return super.onPrepareOptionsMenu(menu);
}
代码示例来源:origin: rsiebert/TVHClient
@Override
public void onPrepareOptionsMenu(Menu menu) {
final boolean showGenreColors = sharedPreferences.getBoolean("genre_colors_for_channels_enabled", false);
final boolean showChannelTagMenu = sharedPreferences.getBoolean("channel_tag_menu_enabled", true);
menu.findItem(R.id.menu_genre_color_info_channels).setVisible(showGenreColors);
menu.findItem(R.id.menu_timeframe).setVisible(isUnlocked);
// Prevent the channel tag menu item from going into the overlay menu
if (showChannelTagMenu) {
menu.findItem(R.id.menu_tags).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
}
代码示例来源:origin: derry/delion
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int tintColor = ContextCompat.getColor(this, R.color.light_normal_color);
Drawable tintedRefresh = ContextCompat.getDrawable(this, R.drawable.btn_toolbar_reload);
tintedRefresh.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
menu.add(0, R.id.menu_id_refresh, 1, R.string.physical_web_refresh)
.setIcon(tintedRefresh)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, R.id.menu_id_close, 2, R.string.close)
.setIcon(R.drawable.btn_close)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: stackoverflow.com
private final int MenuItem_EditId = 1, MenuItem_DeleteId = 0;
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuItem edit_item = menu.add(0, MenuItem_EditId, 0, R.string.edit);
edit_item.setIcon(R.drawable.edit);
edit_item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
MenuItem delete_item = menu.add(0, MenuItem_DeleteId, 1, R.string.edit);
delete_item.setIcon(R.drawable.delete);
delete_item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: duanyuGit/AoLaiDaTi
@Override public boolean onCreateOptionsMenu(Menu menu) {
MenuItem item = menu.add(0, 0, 1, R.string.open_service_button);
item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
MenuItem notifyitem = menu.add(0, 3, 2, R.string.dati_page);
notifyitem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
//
MenuItem about = menu.add(0, 4, 4, R.string.about_title);
about.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_RESET, 0, getResources().getString(R.string.clear))
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
代码示例来源:origin: rsiebert/TVHClient
@Override
public void onPrepareOptionsMenu(Menu menu) {
final boolean showGenreColors = sharedPreferences.getBoolean("genre_colors_for_channels_enabled",
activity.getResources().getBoolean(R.bool.pref_default_genre_colors_for_channels_enabled));
final boolean showChannelTagMenu = sharedPreferences.getBoolean("channel_tag_menu_enabled",
activity.getResources().getBoolean(R.bool.pref_default_channel_tag_menu_enabled));
if (TextUtils.isEmpty(searchQuery)) {
menu.findItem(R.id.menu_genre_color_info_channels).setVisible(showGenreColors);
menu.findItem(R.id.menu_timeframe).setVisible(isUnlocked);
menu.findItem(R.id.menu_search).setVisible((recyclerViewAdapter.getItemCount() > 0));
// Prevent the channel tag menu item from going into the overlay menu
if (showChannelTagMenu) {
menu.findItem(R.id.menu_tags).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
} else {
menu.findItem(R.id.menu_genre_color_info_channels).setVisible(false);
menu.findItem(R.id.menu_timeframe).setVisible(false);
menu.findItem(R.id.menu_search).setVisible(false);
menu.findItem(R.id.menu_tags).setVisible(false);
}
}
代码示例来源:origin: derry/delion
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (mIsAddMode) {
mSaveButton = menu.add(R.string.save)
.setIcon(R.drawable.bookmark_check_gray)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} else {
mDeleteButton = menu.add(R.string.bookmark_action_bar_delete)
.setIcon(TintedDrawable.constructTintedDrawable(
getResources(), R.drawable.btn_trash))
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.searchview_in_menu, menu);
//find the search view item and inflate it in the menu layout
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) searchItem.getActionView();
//set a hint on the search view (optional)
mSearchView.setQueryHint(getString(R.string.search));
//these flags together with the search view layout expand the search view in the landscape mode
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
| MenuItem.SHOW_AS_ACTION_ALWAYS);
//expand the search view when entering the activity(optional)
searchItem.expandActionView();
return true;
}
代码示例来源:origin: stackoverflow.com
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW );
mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Log.d(TAG, "onCreateOptionsMenu()");
inflater.inflate(R.menu.your_menu, menu);
for (int j = 0; j < menu.size(); j++) {
MenuItem item = menu.getItem(j);
Log.d(TAG, "set flag for " + item.getTitle());
item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
}
代码示例来源:origin: derry/delion
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mDeleteButton = menu.add(R.string.bookmark_action_bar_delete)
.setIcon(TintedDrawable.constructTintedDrawable(
getResources(), R.drawable.btn_trash))
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: morogoku/MTweaks-KernelAdiutorMOD
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (!hideBanner()) return;
if (showViewPager()) {
menu.add(0, 0, Menu.NONE, R.string.options)
.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_launcher_preview))
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
if (showTopFab()) {
menu.add(0, 1, Menu.NONE, R.string.more)
.setIcon(getTopFabDrawable())
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} else if (showBottomFab()) {
menu.add(0, 1, Menu.NONE, R.string.more)
.setIcon(getBottomFabDrawable())
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
}
代码示例来源:origin: qiubiteme/android_api_demos
private void setupSearchView(MenuItem searchItem) {
if (isAlwaysExpanded()) {
mSearchView.setIconifiedByDefault(false);
} else {
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
}
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
// Try to use the "applications" global search provider
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
代码示例来源:origin: THEONE10211024/ApiDemos
private void setupSearchView(MenuItem searchItem) {
if (isAlwaysExpanded()) {
mSearchView.setIconifiedByDefault(false);
} else {
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
}
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
// Try to use the "applications" global search provider
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
内容来源于网络,如有侵权,请联系作者删除!