本文整理汇总了Java中android.view.Menu.findItem方法的典型用法代码示例。如果您正苦于以下问题:Java Menu.findItem方法的具体用法?Java Menu.findItem怎么用?Java Menu.findItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Menu
的用法示例。
在下文中一共展示了Menu.findItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的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;
}
示例2: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu (Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem item = menu.findItem(R.id.action_enable);
item.setActionView(R.layout.switch_layout);
SwitchCompat mSwitchEnablePush = item.getActionView().findViewById(R.id.switchForActionBar);
mSwitchEnablePush.setChecked(PushController.isAllEnable(this));
mSwitchEnablePush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
PushController.setAllEnable(b, MainActivity.this);
Toast.makeText(MainActivity.this,
b ? R.string.msg_enable : R.string.msg_disable
, Toast.LENGTH_SHORT).show();
}
});
return true;
}
示例3: onPrepareOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.action_wrap_lines);
MenuItem menuItemDownload = menu.findItem(R.id.action_download);
MenuItem menuItemViewFile = menu.findItem(R.id.action_view_file);
MenuItem menuItemRefresh = menu.findItem(R.id.action_refresh);
if(ViewerActivity.ViewerType.RepoFile.equals(mPresenter.getViewerType())) {
menuItem.setVisible(mPresenter.isCode() && !StringUtils.isBlank(mPresenter.getDownloadSource()));
menuItem.setChecked(wrap);
menuItemDownload.setVisible(!StringUtils.isBlank(mPresenter.getFileModel().getDownloadUrl()));
menuItemViewFile.setVisible(false);
menuItemRefresh.setVisible(true);
} else if(ViewerActivity.ViewerType.DiffFile.equals(mPresenter.getViewerType())){
menuItem.setVisible(true);
menuItem.setChecked(wrap);
menuItemDownload.setVisible(false);
menuItemViewFile.setVisible(true);
menuItemRefresh.setVisible(false);
} else if(ViewerActivity.ViewerType.Image.equals(mPresenter.getViewerType())) {
menuItem.setVisible(false);
menuItemViewFile.setVisible(false);
menuItemRefresh.setVisible(false);
}
}
示例4: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(mPresenter.getRepository() != null){
getMenuInflater().inflate(R.menu.menu_repository, menu);
MenuItem starItem = menu.findItem(R.id.action_star);
MenuItem bookmark = menu.findItem(R.id.action_bookmark);
starItem.setTitle(mPresenter.isStarred() ? R.string.unstar : R.string.star);
starItem.setIcon(mPresenter.isStarred() ?
R.drawable.ic_star_title : R.drawable.ic_un_star_title);
menu.findItem(R.id.action_watch).setTitle(mPresenter.isWatched() ?
R.string.unwatch : R.string.watch);
menu.findItem(R.id.action_fork).setTitle(mPresenter.isFork() ?
R.string.forked : R.string.fork);
menu.findItem(R.id.action_fork).setVisible(mPresenter.isForkEnable());
bookmark.setTitle(mPresenter.isBookmarked() ?
getString(R.string.remove_bookmark) : getString(R.string.bookmark));
menu.findItem(R.id.action_wiki).setVisible(mPresenter.getRepository().isHasWiki());
}
return true;
}
示例5: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (showReloadPlacesButton) {
getMenuInflater().inflate(R.menu.main_menu, menu);
final MenuItem myActionMenuItem = menu.findItem(R.id.action_refresh);
myActionMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
PlaceFragment placeFragment = (PlaceFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (placeFragment.isAdded()) {
placeFragment.currentPlace();
}
return false;
}
});
}
return super.onCreateOptionsMenu(menu);
}
示例6: onPrepareOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
if (app == null) {
return true;
}
MenuItem itemIgnoreAll = menu.findItem(R.id.action_ignore_all);
if (itemIgnoreAll != null) {
itemIgnoreAll.setChecked(app.getPrefs(this).ignoreAllUpdates);
}
MenuItem itemIgnoreThis = menu.findItem(R.id.action_ignore_this);
if (itemIgnoreThis != null) {
itemIgnoreThis.setVisible(app.hasUpdates());
itemIgnoreThis.setChecked(app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode);
}
return true;
}
示例7: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_edit, menu);
if (mPreviewMode) {
MenuItem item = menu.findItem(R.id.action_preview);
item.setIcon(R.drawable.ic_edit);
item.setTitle(R.string.action_edit);
}
return true;
}
示例8: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem item = menu.findItem(R.id.menu_store);
if (developerUrl != null) {
item.setVisible(true);
}
return true;
}
示例9: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItem importItem = menu.findItem(R.id.action_import);
importItem.setVisible(true);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getString(R.string.search));
searchView.onActionViewExpanded();
searchView.clearFocus();
searchView.setSubmitButtonEnabled(false);
searchView.setQueryRefinementEnabled(false);
searchView.setOnQueryTextListener(this);
}
示例10: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_empresas, menu);
final MenuItem searchItem = menu.findItem(R.id.item_buscar_empresas);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
}
示例11: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.cast_browse, menu);
mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
R.id.media_route_menu_item);
mQueueMenuItem = menu.findItem(R.id.action_show_queue);
showIntroductoryOverlay();
return true;
}
示例12: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_locatr, menu);
MenuItem searchItem = menu.findItem(R.id.action_locate);
searchItem.setEnabled(mClient.isConnected());
}
示例13: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu_toolbar, menu);
MenuItem menuItemQRCode = menu.findItem(R.id.menu_items_qrcode);
menuItemQRCode.setVisible(useToolbarActionQRCode());
return super.onCreateOptionsMenu(menu);
}
示例14: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);
// Associate searchable configuration with the SearchView
menuItemRefresh = menu.findItem(R.id.menu_refresh);
menuItemRefresh.setVisible(false);
menuItemNews = menu.findItem(R.id.menu_notification);
MenuItemBadge.update(this, menuItemNews, new MenuItemBadge.Builder()
.iconDrawable(ContextCompat.getDrawable(this, R.drawable.ic_notification_md))
.iconTintColor(Color.WHITE)
.textBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent))
.textColor(ContextCompat.getColor(this, R.color.colorPrimary)));
updateNewsBadgeCount(AppManager.getInstance().newsList);
menuItemPoints = menu.findItem(R.id.menu_points);
MenuItemBadge.update(this, menuItemPoints, new MenuItemBadge.Builder()
.iconDrawable(ContextCompat.getDrawable(this, R.drawable.ic_sack_md))
.iconTintColor(Color.WHITE)
.textBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent))
.textColor(ContextCompat.getColor(this, R.color.colorPrimary)));
MenuItemBadge.getBadgeTextView(menuItemPoints).setText(String.valueOf(raffles_point));
showTip();
return true;
}
示例15: onCreateOptionsMenu
import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.detail, menu);
MenuItem menuItem = menu.findItem(R.id.action_share);
menuItem.setIntent(createShareForecastIntent());
return true;
}