當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。