本文整理汇总了Java中android.view.MenuItem.OnMenuItemClickListener类的典型用法代码示例。如果您正苦于以下问题:Java OnMenuItemClickListener类的具体用法?Java OnMenuItemClickListener怎么用?Java OnMenuItemClickListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnMenuItemClickListener类属于android.view.MenuItem包,在下文中一共展示了OnMenuItemClickListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLogcatButton
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
public void addLogcatButton(Menu menu) {
if (!ReplApplication.isAcraActive()) { // If ACRA isn't active
return; // we don't show the button
}
MenuItem showSettingsItem = menu.add(Menu.NONE, Menu.NONE, 4,
"Send Error Report").setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
String reportId = genReportId();
ReplApplication.reportError(null, reportId);
Notifier.oneButtonAlert(activeForm, "Your Report Id is: " + reportId +
"<br />Use this ID when reporting this error.", "Error Report Id", "OK");
return true;
}
});
showSettingsItem.setIcon(android.R.drawable.stat_sys_warning);
}
示例2: createOptionsMenuItem
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
protected void createOptionsMenuItem(final Activity source, Menu menu) {
if(Socialize.getSocialize().isAuthenticated()) {
MenuItem add = menu.add(localizationService.getString(I18NConstants.SETTINGS_HEADER));
if(drawables != null) {
add.setIcon(drawables.getDrawable("ic_menu_preferences.png"));
}
add.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if(!onSettingsMenuItemClick(item)) {
UserUtils.showUserSettingsForResult(source, CommentActivity.PROFILE_UPDATE);
}
return true;
}
});
}
}
示例3: createOptionsMenuItem
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
protected void createOptionsMenuItem(Activity source, Menu menu) {
super.createOptionsMenuItem(source, menu);
MenuItem add2 = menu.add("Refresh");
if(drawables != null) {
add2.setIcon(drawables.getDrawable("ic_menu_refresh.png"));
}
add2.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if(onCommentViewActionListener == null || !onCommentViewActionListener.onRefreshMenuItemClick(item)) {
reload();
}
return true;
}
});
}
示例4: onPrepareOptionsMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
if(menu.size() > 0)
{
return true;
}
//Add the 'Back' Menu Item
MenuItem back = menu.add(Menu.NONE, Menu.NONE, 0, "Back");
back.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem clickedItem)
{
//Load the New Ticket screen
SyncWebApp.this.webView.loadUrl("file:///android_asset/html/api/api.html");
return true;
}
});
return true;
}
示例5: postRender
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
public void postRender()
{
//setup menu
Menu menu = (Menu)NavigationContext.getInstance().
getAttribute("options-menu");
if(menu != null)
{
MenuItem backItem = menu.add(0, 0, 0, "Back");
backItem.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem clickedItem)
{
Services.getInstance().getNavigationContext().back();
return true;
}
});
}
}
示例6: postRender
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
public void postRender()
{
//setup menu
Menu menu = (Menu)NavigationContext.getInstance().
getAttribute("options-menu");
if(menu != null)
{
MenuItem backItem = menu.add(0, 0, 0, "Back");
backItem.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem clickedItem)
{
Services.getInstance().getNavigationContext().back();
return true;
}
});
}
}
示例7: setupMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
private void setupMenu()
{
Menu menu = (Menu)NavigationContext.getInstance().
getAttribute("options-menu");
if(menu != null)
{
MenuItem serverItem = menu.add(Menu.NONE, Menu.NONE, 0, "Change Cloud IP Address");
serverItem.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem clickedItem)
{
try
{
HomeScreen.this.changeCloudServer();
return true;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
});
}
}
示例8: addOnActionToMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
public void addOnActionToMenu(final ActionButtonCallback actionItem, final Menu menu, boolean showIcon) {
menu.add(arch16n.substituteValue(actionItem.actionOnLabel()));
if (showIcon) {
menu.getItem(menu.size()-1).setIcon(R.drawable.toggle_on);
}
menu.getItem(menu.size()-1).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
actionItem.actionOn();
updateActionBar(menu);
} catch (Exception e) {
showActionError(actionItem, e);
}
return false;
}
});
}
示例9: addOffActionToMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
public void addOffActionToMenu(final ToggleActionButtonCallback actionItem, final Menu menu) {
menu.add(arch16n.substituteValue(actionItem.actionOffLabel()));
menu.getItem(menu.size()-1).setIcon(R.drawable.toggle_off);
menu.getItem(menu.size()-1).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
actionItem.actionOff();
updateActionBar(menu);
} catch (Exception e) {
showActionError(actionItem, e);
}
return false;
}
});
}
示例10: onCreateOptionsMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
menu.clear();
// ActionBarの全削除ボタンを追加
final MenuItem menuItem = menu.add(R.string.delete_all);
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem item) {
if (item.getTitle().equals(menuItem.getTitle())) {
deleteAllTokenProc();
}
return true;
}
});
}
示例11: onCreateOptionsMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem temp = menu.add("Clear all notifications").setIcon(android.R.drawable.ic_menu_delete).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.contacts_add, null);
new AlertDialog.Builder(getActivity()).setTitle("Add peasant to collection").setView(view).setPositiveButton("Add", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setNegativeButton("Cancel", null).show();
return true;
}
});
if (VERSION.SDK_INT >= 11) temp.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
示例12: onCreateContextMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
mSelectedPosition = info.position;
mTrackCursor.moveToPosition(mSelectedPosition);
mCurrentTrackName = mTrackCursor.getString(mTrackCursor.getColumnIndexOrThrow(
Media.MediaColumns.TITLE));
menu.setHeaderTitle(mCurrentTrackName);
android.view.MenuItem remove = menu.add(R.string.remove_from_playlist);
remove.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(android.view.MenuItem arg0) {
removePlaylistItem(mSelectedPosition);
return true;
}
});
}
示例13: onCreateOptionsMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.search, menu);
menu.add(Menu.NONE, Menu.FIRST + 1, 1, "扫描条形码")
.setIcon(R.drawable.barcode)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent openCameraIntent = new Intent(
SearchActivity.this, CaptureActivity.class);
startActivityForResult(openCameraIntent, 0);
return false;
}
});
return true;
}
示例14: onCreateOptionsMenu
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
@SuppressLint({ "InlinedApi", "NewApi" })
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem menuItem = menu.add("Map").setOnMenuItemClickListener(new OnMenuItemClickListener(){
@Override
public boolean onMenuItemClick (MenuItem item){
// Using static global variable to pass data. Avoid this in your app (memory leaks etc)!
PackageManagerActivity.dataSource = new PackageManagerTileDataSource(PackageManagerActivity.this.packageManager);
Intent myIntent = new Intent(PackageManagerActivity.this,
PackagedMapActivity.class);
PackageManagerActivity.this.startActivity(myIntent);
return true;
}
});
menuItem.setIcon(android.R.drawable.ic_dialog_map);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
return super.onCreateOptionsMenu(menu);
}
示例15: addLanguageMenuOption
import android.view.MenuItem.OnMenuItemClickListener; //导入依赖的package包/类
private void addLanguageMenuOption(final Menu menu, String text, final String value) {
MenuItem menuItem = menu.add(text).setOnMenuItemClickListener(new OnMenuItemClickListener(){
@Override
public boolean onMenuItemClick (MenuItem item){
for (int i = 0; i < menu.size(); i++) {
MenuItem otherItem = menu.getItem(i);
if (otherItem == item) {
otherItem.setIcon(android.R.drawable.checkbox_on_background);
} else {
otherItem.setIcon(null);
}
}
vectorStyleLang = value;
updateBaseLayer();
return true;
}
});
if (vectorStyleLang.equals(value)) {
menuItem.setIcon(android.R.drawable.checkbox_on_background);
}
}