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); }
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; } }); } }
@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; } }); }
@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; }
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; } }); } }
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); } } }); } }
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; } }); }
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; } }); }
@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; } }); }
@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); }
@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; } }); }
@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; }
@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); }
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); } }
private void addStyleMenuOption(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); } } vectorStyleName = value; updateBaseLayer(); return true; } }); if (vectorStyleName.equals(value)) { menuItem.setIcon(android.R.drawable.checkbox_on_background); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem sendItem = menu.add(0, 0, 0, "发送"); sendItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); sendItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { initData(); return false; } }); return super.onCreateOptionsMenu(menu); }
private static void setOnMenuItemClickListenerRecursive(Menu menu,OnMenuItemClickListener listener) { List<Menu> menus=new ArrayList<>(1); menus.add(menu); while(!menus.isEmpty()) { final Menu currentMenu=menus.remove(0); for(int i=0;i<currentMenu.size();++i) { final MenuItem item=currentMenu.getItem(i); item.setOnMenuItemClickListener(listener); final SubMenu subMenu=item.getSubMenu(); if(subMenu!=null) menus.add(subMenu); } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Reset").setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { gridview.setAdapter(new ExamplePagedDragDropGridAdapter(MainActivity.this, gridview)); gridview.notifyDataSetChanged(); return true; } }); return true; }
private void analyzeUserMenu(final Adapter adapter, final User user, ContextMenu menu, final Context context) { menu.setHeaderTitle(R.string.menu_title_blog); int order = 0; MenuItem commentMenu = menu.add(0, 1, order++, R.string.menu_group_member_user_profile); Intent commentIntent = new Intent(context, ProfileActivity.class); commentIntent.putExtra("USER", user); commentMenu.setIntent(commentIntent); MenuItem unfollowMenu = menu.add(0, 2, order++, R.string.menu_group_member_unfollow); unfollowMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { CacheAdapter<User> cacheAdapter = (CacheAdapter<User>)AdapterUtil.getCacheAdapter(adapter); GroupMemberUnfollowTask task = new GroupMemberUnfollowTask(cacheAdapter, user); task.execute(); return false; } }); MenuItem messageMenu = menu.add(0, 2, order++, R.string.menu_group_member_message); Intent messageIntent = new Intent(context, EditDirectMessageActivity.class); messageIntent.putExtra("DISPLAY_NAME", user.getDisplayName()); messageMenu.setIntent(messageIntent); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == R.id.recordsListView) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; record = new RecordService(getActivity()).findById(info.id); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.record_context, menu); OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }; for (int i = 0, n = menu.size(); i < n; i++) menu.getItem(i).setOnMenuItemClickListener(listener); } }
private void initSlideShowMenuItem(Menu menu) { MenuItem slideShowMenuItem = menu.findItem(R.id.action_slideshow); slideShowMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if(mSession != null && mSession.hasStarted() && photoSet != null && photoSet.size() > 0) { sendPhotoSet(); Toast.makeText(HipstaActivity.this, "Starting slideshow on ChromeCast!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(HipstaActivity.this, "Please connect to cast device first.", Toast.LENGTH_SHORT).show(); } return false; } }); }
private void initRefreshMenuItem(Menu menu) { MenuItem refreshMenuItem = menu.findItem(R.id.action_refresh); refreshMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if(gridView != null) { ((GridViewAdapter) gridView.getAdapter()).clear(); gridView.setAlpha(0.2f); pageOffset = 0; new LoadImageListTask(HipstaActivity.this, pageOffset, IMAGES_PER_FETCH).execute(preferences.getString("tagsPref", DEFAULT_SEARCH_TAG)); } return false; } }); }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); //添加菜单项 MenuItem add=menu.add(0, 0, 0, R.string.menu_checkin); //绑定到ActionBar add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); //绑定点击事件 add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { //创建新微博 checkinWithCurrentPoi(); return false; } }); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); //添加菜单项 MenuItem add = menu.add(0, 0, 0, getString(R.string.menu_map)); //绑定到ActionBar add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); //绑定点击事件 add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if(mPoi != null) { BaiduMapActivity.openMapWithMarker(ActivityDetailPoi.this, mPoi.latitude, mPoi.longtitude, mPoi.title, mPoi.address); } else { SmartToast.showLongToast(ActivityDetailPoi.this, R.string.hint_location_invalid, false); } return false; } }); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); //添加菜单项 MenuItem add=menu.add(0, 0, 0, R.string.menu_send); //绑定到ActionBar add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); //绑定点击事件 add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { checkAndComment(); return false; } }); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { //签到按钮 MenuItem add = menu.add(0, 0, 0, getString(R.string.menu_checkin)); add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { //拍照并创建新微博 Intent it = new Intent(ActivityPopularPOIs.this, ActivityNewWeibo.class); it.putExtra(ActivityNewWeibo.INTENT_EXTRA_TAKE_PHOTO, true); startActivity(it); return false; } }); //创建基类的按钮 super.onCreateOptionsMenu(menu); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); //添加菜单项 MenuItem add = menu.add(0, 0, 0, R.string.menu_send); //绑定到ActionBar add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); //绑定点击事件 add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { checkAndPost(); return false; } }); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); //添加菜单项 MenuItem add = menu.add(0, 0, 0, R.string.menu_save); //绑定到ActionBar add.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); //绑定点击事件 add.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { saveImage(); return false; } }); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); MenuItem settingItem = menu.findItem(R.id.action_settings); settingItem.setOnMenuItemClickListener(new OnSettingClickedListener(this)); MenuItem downloadItem = menu.findItem(R.id.action_download); downloadItem.setOnMenuItemClickListener(new OnMenuItemClickListener(){ @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(MusicPlayerActivity.this, DownloadingActivity.class); startActivity(intent); return true; } }); MenuItem playItem = menu.findItem(R.id.action_play); playItem.setVisible(false); return super.onCreateOptionsMenu(menu); }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem reset = menu.add(R.string.menu_colors_reset); reset.setAlphabeticShortcut('r'); reset.setNumericShortcut('1'); reset.setIcon(android.R.drawable.ic_menu_revert); reset.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem arg0) { // Reset each individual color to defaults. for (int i = 0; i < Colors.defaults.length; i++) { if (mColorList[i] != Colors.defaults[i]) { mHostDb.setGlobalColor(i, Colors.defaults[i]); mColorList[i] = Colors.defaults[i]; } } mColorGrid.invalidateViews(); // Reset the default FG/BG colors as well. mFgSpinner.setSelection(HostDatabase.DEFAULT_FG_COLOR); mBgSpinner.setSelection(HostDatabase.DEFAULT_BG_COLOR); mHostDb.setDefaultColorsForScheme(HostDatabase.DEFAULT_COLOR_SCHEME, HostDatabase.DEFAULT_FG_COLOR, HostDatabase.DEFAULT_BG_COLOR); return true; } }); return true; }
@Override void onCreateContextMenuForChild(final int childPosition, ContextMenu menu, Activity activity) { if (isMoreButton(childPosition)) return; OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.closeTab(getChild(childPosition)); return true; } }; menu.add(R.string.close_tab).setOnMenuItemClickListener(listener); }
@Override public void onCreateContextMenuForChild(int childPosition, ContextMenu menu, Activity activity) { final ForeignSessionTab foreignSessionTab = getChild(childPosition); OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab, WindowOpenDisposition.NEW_BACKGROUND_TAB); return true; } }; menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener); }
public void addExitButtonToMenu(Menu menu) { MenuItem stopApplicationItem = menu.add(Menu.NONE, Menu.NONE, Menu.FIRST, "Stop this application") .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { showExitApplicationNotification(); return true; } }); stopApplicationItem.setIcon(android.R.drawable.ic_notification_clear_all); }