本文整理了Java中android.app.Activity.onMenuItemSelected()
方法的一些代码示例,展示了Activity.onMenuItemSelected()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.onMenuItemSelected()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:onMenuItemSelected
暂无
代码示例来源:origin: robolectric/robolectric
/**
* Perform a click on a menu item.
*
* @param menuItemResId Menu item resource ID.
* @return True if the click was handled, false otherwise.
*/
public boolean clickMenuItem(int menuItemResId) {
final RoboMenuItem item = new RoboMenuItem(menuItemResId);
return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
}
代码示例来源:origin: matrixxun/MaterialBadgeTextView
@Override
public void onClick(View v) {
boolean consumed = false;
if (listener != null) {
consumed = listener.onOptionsItemSelected(menu);
}
if (!consumed) {
activity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, menu);
}
}
});
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param featureId
* @param item
* @return
* @see android.app.Activity#onMenuItemSelected(int, android.view.MenuItem)
*/
public boolean onMenuItemSelected(int featureId,
MenuItem item) {
return mActivity.onMenuItemSelected(featureId, item);
}
代码示例来源:origin: iqiyi/Neptune
@Override
public boolean onMenuItemSelected(int int0, android.view.MenuItem menuitem1) {
return mOriginActivity.onMenuItemSelected(int0, menuitem1);
}
代码示例来源:origin: org.robolectric/shadows-framework
/**
* Perform a click on a menu item.
*
* @param menuItemResId Menu item resource ID.
* @return True if the click was handled, false otherwise.
*/
public boolean clickMenuItem(int menuItemResId) {
final RoboMenuItem item = new RoboMenuItem(menuItemResId);
return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
}
代码示例来源:origin: nshmura/strictmode-notifier
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onMenuItemSelected(featureId, item);
}
代码示例来源:origin: netmackan/ATimeTracker
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case Activities.EXPORT_VIEW:
requestExport();
break;
default:
// Ignore the other menu items; they're context menu
break;
}
return super.onMenuItemSelected(featureId, item);
}
代码示例来源:origin: shazam/android-aspects
@Override
public boolean onMenuItemSelected(int featureId, @NonNull MenuItem item) {
return super.onMenuItemSelected(featureId, item) || dispatcher.dispatchOnMenuItemSelected(this, featureId, item);
}
代码示例来源:origin: org.robolectric/shadows-core-v23
/**
* Perform a click on a menu item.
*
* @param menuItemResId Menu item resource ID.
* @return True if the click was handled, false otherwise.
*/
public boolean clickMenuItem(int menuItemResId) {
if (optionsMenu == null) {
throw new RuntimeException(
"Activity does not have an options menu! Did you forget to call " +
"super.onCreateOptionsMenu(menu) in " + realActivity.getClass().getName() + "?");
}
final RoboMenuItem item = new RoboMenuItem(menuItemResId);
return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
}
代码示例来源:origin: org.robolectric/framework
/**
* Perform a click on a menu item.
*
* @param menuItemResId Menu item resource ID.
* @return True if the click was handled, false otherwise.
*/
public boolean clickMenuItem(int menuItemResId) {
if (optionsMenu == null) {
throw new RuntimeException(
"Activity does not have an options menu! Did you forget to call " +
"super.onCreateOptionsMenu(menu) in " + realActivity.getClass().getName() + "?");
}
final RoboMenuItem item = new RoboMenuItem(menuItemResId);
return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
}
代码示例来源:origin: org.robolectric/shadows-core
/**
* Perform a click on a menu item.
*
* @param menuItemResId Menu item resource ID.
* @return True if the click was handled, false otherwise.
*/
public boolean clickMenuItem(int menuItemResId) {
if (optionsMenu == null) {
throw new RuntimeException(
"Activity does not have an options menu! Did you forget to call " +
"super.onCreateOptionsMenu(menu) in " + realActivity.getClass().getName() + "?");
}
final RoboMenuItem item = new RoboMenuItem(menuItemResId);
return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
}
代码示例来源:origin: xia-weiyang/MainScreenShow
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.action_delete:
delete = !delete;
pA.notifyDataSetChanged();
break;
case R.id.action_add:
Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
break;
default:
break;
}
return super.onMenuItemSelected(featureId, item);
}
代码示例来源:origin: xia-weiyang/MainScreenShow
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_preview:
startActivity(new Intent()
.setClass(MSSEvent.this, MSSPreview.class));
break;
case R.id.menu_settings:
startActivity(new Intent().setClass(MSSEvent.this, Setting.class));
break;
case R.id.menu_exit:
new AlertDialog.Builder(MSSEvent.this).setTitle(R.string.action_warn)
.setMessage(R.string.tip_exit)
.setPositiveButton(R.string.action_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
stopService(new Intent().setClass(MSSEvent.this,
MSSService.class));
System.exit(0);
}
}).setNegativeButton(R.string.action_cancel, null).show();
break;
default:
break;
}
return super.onMenuItemSelected(featureId, item);
}
代码示例来源:origin: xia-weiyang/MainScreenShow
return super.onMenuItemSelected(featureId, item);
代码示例来源:origin: com.google.android/support-v4
/**
* Dispatch context and options menu to fragments.
*/
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (super.onMenuItemSelected(featureId, item)) {
return true;
}
switch (featureId) {
case Window.FEATURE_OPTIONS_PANEL:
return mFragments.dispatchOptionsItemSelected(item);
case Window.FEATURE_CONTEXT_MENU:
return mFragments.dispatchContextItemSelected(item);
default:
return false;
}
}
代码示例来源:origin: nickrussler/Android-Wifi-Hotspot-Manager-Class
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case 0:
scan();
break;
case 1:
wifiApManager.setWifiApEnabled(null, true);
break;
case 2:
wifiApManager.setWifiApEnabled(null, false);
break;
}
return super.onMenuItemSelected(featureId, item);
}
}
代码示例来源:origin: kingargyle/adt-leanback-support
/**
* Dispatch context and options menu to fragments.
*/
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (super.onMenuItemSelected(featureId, item)) {
return true;
}
switch (featureId) {
case Window.FEATURE_OPTIONS_PANEL:
return mFragments.dispatchOptionsItemSelected(item);
case Window.FEATURE_CONTEXT_MENU:
return mFragments.dispatchContextItemSelected(item);
default:
return false;
}
}
代码示例来源:origin: xia-weiyang/MainScreenShow
break;
return super.onMenuItemSelected(featureId, item);
代码示例来源:origin: ELynx/pokemon-go-xposed-mitm
public boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
if (ScriptLoader.isCalledFromJRuby()) return super.onMenuItemSelected(featureId, item);
if (!JRubyAdapter.isInitialized()) {
Log.i("Method called before JRuby runtime was initialized: RubotoActivity#onMenuItemSelected");
return super.onMenuItemSelected(featureId, item);
}
String rubyClassName = scriptInfo.getRubyClassName();
if (rubyClassName == null) return super.onMenuItemSelected(featureId, item);
if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :onMenuItemSelected}")) {
return (Boolean) JRubyAdapter.runRubyMethod(Boolean.class, scriptInfo.getRubyInstance(), "onMenuItemSelected", new Object[]{featureId, item});
} else {
if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :on_menu_item_selected}")) {
return (Boolean) JRubyAdapter.runRubyMethod(Boolean.class, scriptInfo.getRubyInstance(), "on_menu_item_selected", new Object[]{featureId, item});
} else {
if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(true).any?{|m| m.to_sym == :on_menu_item_selected}")) {
return (Boolean) JRubyAdapter.runRubyMethod(Boolean.class, scriptInfo.getRubyInstance(), "on_menu_item_selected", new Object[]{featureId, item});
} else {
return (Boolean) JRubyAdapter.runRubyMethod(Boolean.class, scriptInfo.getRubyInstance(), "onMenuItemSelected", new Object[]{featureId, item});
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!