当前位置: 首页>>代码示例>>Java>>正文


Java OnMenuItemClickListener类代码示例

本文整理汇总了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);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:18,代码来源:ReplForm.java

示例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;
			}
		});
	}
}
 
开发者ID:dylanmaryk,项目名称:InsanityRadio-Android,代码行数:20,代码来源:SocializeBaseView.java

示例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;
		}
	});
}
 
开发者ID:dylanmaryk,项目名称:InsanityRadio-Android,代码行数:21,代码来源:CommentView.java

示例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;
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:23,代码来源:SyncWebApp.java

示例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;
			}
		});
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:20,代码来源:LocalScreen.java

示例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;
			}
		});
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:20,代码来源:RemoteScreen.java

示例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);
				}
			}
		});
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:26,代码来源:HomeScreen.java

示例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;
		}
	});
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:20,代码来源:ShowModuleMenuManager.java

示例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;
		}
	});
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:18,代码来源:ShowModuleMenuManager.java

示例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;
        }
    });
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:17,代码来源:AccessTokenListFragment.java

示例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);
}
 
开发者ID:Ezard,项目名称:CropOp,代码行数:17,代码来源:NOtificationsFragment.java

示例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;
}
     });
 }
 
开发者ID:wseemann,项目名称:ServeStream,代码行数:19,代码来源:NowPlayingActivity.java

示例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;
}
 
开发者ID:yuanguozheng,项目名称:XiyouLibrary,代码行数:19,代码来源:SearchActivity.java

示例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);
}
 
开发者ID:nutiteq,项目名称:hellomap3d-android,代码行数:26,代码来源:PackageManagerActivity.java

示例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);
		}
	}
 
开发者ID:nutiteq,项目名称:hellomap3d-android,代码行数:24,代码来源:VectorMapSampleBaseActivity.java


注:本文中的android.view.MenuItem.OnMenuItemClickListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。