List of usage examples for android.view MenuItem setIcon
public MenuItem setIcon(@DrawableRes int iconRes);
From source file:tv.acfun.video.DetailsActivity.java
private void handleFav(final MenuItem item) { if (isFaved) { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override//from ww w . ja v a 2s . c o m public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { new Thread() { public void run() { boolean deleteFavourite = MemberUtils.deleteFavourite( API.getDomainRoot(getApplicationContext()), String.valueOf(mAcId), mCookies); //TODO ?? isFaved = !deleteFavourite; Log.i("Delete", "deleteFavourite::" + mAcId + ":" + deleteFavourite); } }.start(); item.setTitle("?"); item.setIcon(R.drawable.ic_action_favorite); } } }; AcApp.showDeleteFavAlert(this, listener); } else { if (mCookies == null) { Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show(); } else { new Thread() { public void run() { boolean add = MemberUtils.addFavourite(String.valueOf(mAcId), API.getDomainRoot(getApplicationContext()), mCookies); //TODO ?? Log.i("add", "addFavourite::" + mAcId + ":" + add); } }.start(); item.setTitle("??"); item.setIcon(R.drawable.ic_action_favorited); } } }
From source file:com.crearo.gpslogger.GpsMainActivity.java
private void enableDisableMenuItems() { onWaitingForLocation(Session.isWaitingForLocation()); setBulbStatus(Session.isStarted());/*from ww w .ja v a 2s .c o m*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarBottom); MenuItem mnuAnnotate = toolbar.getMenu().findItem(R.id.mnuAnnotate); MenuItem mnuOnePoint = toolbar.getMenu().findItem(R.id.mnuOnePoint); MenuItem mnuAutoSendNow = toolbar.getMenu().findItem(R.id.mnuAutoSendNow); if (mnuOnePoint != null) { mnuOnePoint.setEnabled(!Session.isStarted()); mnuOnePoint.setIcon((Session.isStarted() ? R.drawable.singlepoint_disabled : R.drawable.singlepoint)); } if (mnuAutoSendNow != null) { mnuAutoSendNow.setEnabled(Session.isStarted()); } if (mnuAnnotate != null) { if (!preferenceHelper.shouldLogToGpx() && !preferenceHelper.shouldLogToKml() && !preferenceHelper.shouldLogToCustomUrl()) { mnuAnnotate.setIcon(R.drawable.annotate2_disabled); mnuAnnotate.setEnabled(false); } else { if (Session.isAnnotationMarked()) { mnuAnnotate.setIcon(R.drawable.annotate2_active); } else { mnuAnnotate.setIcon(R.drawable.annotate2); } } } }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;//from www .j ava 2 s.com } if (getActivity() instanceof MainActivity) { getMenu(getSession(), menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, R.id.menu_gallery, Menu.FIRST, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity || getActivity() instanceof BaseShortcutActivity) { // permission = // getSession().getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder); if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_CREATE_FOLDER)) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_create_folder, Menu.FIRST, R.string.folder_create); mi.setIcon(R.drawable.ic_repository_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } MenuFragmentHelper.getMenu(getActivity(), menu); }
From source file:com.esri.squadleader.view.SquadLeaderActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { SharedPreferences prefs = getPreferences(MODE_PRIVATE); String key = getString(R.string.pref_labels); if (!prefs.contains(key)) { prefs.edit().putBoolean(key, true).commit(); }//from www . j a v a 2 s. c o m boolean labelsOn = prefs.getBoolean(key, true); if (null != mil2525cController) { mil2525cController.setShowLabels(labelsOn); } MenuItem menuItem_toggleLabels = menu.findItem(R.id.toggle_labels); menuItem_toggleLabels.setIcon(labelsOn ? R.drawable.ic_action_labels : R.drawable.ic_action_labels_off); menuItem_toggleLabels.setChecked(labelsOn); return super.onPrepareOptionsMenu(menu); }
From source file:org.zirco.ui.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem item; item = menu.add(0, MENU_ADD_BOOKMARK, 0, R.string.Main_MenuAddBookmark); item.setIcon(R.drawable.ic_menu_add_bookmark); item = menu.add(0, MENU_SHOW_BOOKMARKS, 0, R.string.Main_MenuShowBookmarks); item.setIcon(R.drawable.ic_menu_bookmarks); item = menu.add(0, MENU_SHOW_DOWNLOADS, 0, R.string.Main_MenuShowDownloads); item.setIcon(R.drawable.ic_menu_downloads); item = menu.add(0, MENU_PREFERENCES, 0, R.string.Main_MenuPreferences); item.setIcon(R.drawable.ic_menu_preferences); item = menu.add(0, MENU_EXIT, 0, R.string.Main_MenuExit); item.setIcon(R.drawable.ic_menu_exit); return true;/*from w ww .ja va2 s. c o m*/ }
From source file:com.llwoll.logistics.map.view.widget.br.liveo.navigationliveo.NavigationLiveo.java
private void configureFindView() { mList = (ListView) findViewById(R.id.list); mList.setOnItemClickListener(new DrawerItemClickListener()); mToolbar = (Toolbar) findViewById(R.id.toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerToggle = new ActionBarDrawerToggleCompat(this, mDrawerLayout, mToolbar); mDrawerLayout.setDrawerListener(mDrawerToggle); mTitleFooter = (TextView) this.findViewById(R.id.titleFooter); mIconFooter = (ImageView) this.findViewById(R.id.iconFooter); mFooterDrawer = (RelativeLayout) this.findViewById(R.id.footerDrawer); mRelativeDrawer = (ScrimInsetsFrameLayout) this.findViewById(R.id.relativeDrawer); // mToolbar.setLogo(R.drawable.ic_arrow_left); // mToolbar.setSubtitle("?"); // mToolbar.setTitle("?"); this.setSupportActionBar(mToolbar); // mToolbar.inflateMenu(R.menu.menu_navi_main); // getSupportActionBar(). mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override// ww w .jav a 2 s . c o m public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_edit: if (isMap) { item.setIcon(getResources().getDrawable(R.drawable.icon_list)); // Toast.makeText(context, "is Map", Toast.LENGTH_SHORT).show(); EventBus.getDefault().postSticky(FrontEvent.LIST); isMap = false; } else { item.setIcon(getResources().getDrawable(R.drawable.icon_map)); // Toast.makeText(context, "no Map", Toast.LENGTH_SHORT).show(); EventBus.getDefault().postSticky(FrontEvent.MAP); isMap = true; } break; } return true; } }); // mToolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_left)); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { try { if (!mRemoveHeader || !mCustomHeader) { Resources.Theme theme = this.getTheme(); TypedArray typedArray = theme.obtainStyledAttributes(new int[] { android.R.attr.colorPrimary }); mDrawerLayout.setStatusBarBackground(typedArray.getResourceId(0, 0)); } } catch (Exception e) { e.getMessage(); } this.setElevationToolBar(mElevationToolBar); } }
From source file:com.fa.mastodon.activity.ComposeActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // menu items MenuItem imSettings = menu.findItem(R.id.action_settings); if (imSettings != null) { // set visible is the other is invisible Drawable closeIcon = imSettings.getIcon(); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); imSettings.setIcon(closeIcon); }/*from w w w . ja v a2s . c o m*/ return super.onPrepareOptionsMenu(menu); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
@Override public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { SubMenu subMenuBlueTooth = menu.addSubMenu(this.getString(R.string.lblBluetoothItem)); com.actionbarsherlock.view.MenuItem miBluetooth = subMenuBlueTooth.getItem(); miBluetooth.setIcon(R.drawable.stat_sys_data_bluetooth); miBluetooth.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); com.actionbarsherlock.view.MenuItem miBlueToothDiscover = subMenuBlueTooth .add(R.string.lblBluetoothDiscover).setIcon(R.drawable.ic_menu_allfriends); com.actionbarsherlock.view.MenuItem miBlueToothGetDiscoverable = subMenuBlueTooth .add(R.string.lblBluetoothGetDiscoverable).setIcon(android.R.drawable.ic_menu_myplaces); com.actionbarsherlock.view.MenuItem miBlueToothReceive = subMenuBlueTooth.add(R.string.lblBluetoothReceive) .setIcon(R.drawable.ic_menu_download); com.actionbarsherlock.view.MenuItem miBlueToothHelp = subMenuBlueTooth.add(R.string.lblBluetoothHelp) .setIcon(android.R.drawable.ic_menu_info_details); miBlueToothDiscover.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/* w ww. j a va 2 s. com*/ public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { GameSetHistoryActivity.this.bluetoothHelper.startDiscovery(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothDiscoverDevices); } return true; } }); miBlueToothGetDiscoverable.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { GameSetHistoryActivity.this.bluetoothHelper.setBluetoothDeviceDiscoverable(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothSetDiscoverable); } return true; } }); miBlueToothReceive.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { // retrieve game count int gameSetCount; try { gameSetCount = AppContext.getApplication().getDalService().getGameSetCount(); } catch (DalException de) { gameSetCount = 0; } // prevent user from downloading if game set count > 5 and // limited version if (AppContext.getApplication().isAppLimited() && gameSetCount >= 5) { Toast.makeText(GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getString(R.string.msgLimitedVersionInformation), Toast.LENGTH_SHORT).show(); } // ok for download else { try { GameSetHistoryActivity.this.receiveGameSetTask = new ReceiveGameSetTask( GameSetHistoryActivity.this, GameSetHistoryActivity.this.progressDialog, GameSetHistoryActivity.this.bluetoothHelper.getBluetoothAdapter()); GameSetHistoryActivity.this.receiveGameSetTask.setCallback(refreshCallback); GameSetHistoryActivity.this.receiveGameSetTask.execute(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothReceiveGameSet); } catch (IOException ioe) { Log.v(AppContext.getApplication().getAppLogTag(), "TarotDroid Exception in " + this.getClass().toString(), ioe); Toast.makeText(GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getString(R.string.msgBluetoothError, ioe), Toast.LENGTH_SHORT).show(); } } } return true; } }); miBlueToothHelp.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { UIHelper.showSimpleRichTextDialog(GameSetHistoryActivity.this, AppContext.getApplication().getResources().getText(R.string.msgHelpBluetooth).toString(), AppContext.getApplication().getResources().getString(R.string.titleHelpBluetooth)); return true; } }); // TODO Improve Massive excel export // if (!AppContext.getApplication().isAppLimited()) { // com.actionbarsherlock.view.MenuItem miGlobalExport = // menu.add(this.getString(R.string.lblExcelExport)).setIcon(R.drawable.ic_excel); // miGlobalExport.setShowAsAction(com.actionbarsherlock.view.MenuItem.SHOW_AS_ACTION_NEVER); // //miGlobalExport.setIcon(R.drawable.ic_excel); // // miGlobalExport.setOnMenuItemClickListener(new // OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem // item) { // ExportToExcelTask task = new // ExportToExcelTask(GameSetHistoryActivity.this, progressDialog); // task.execute(); // return true; // } // }); // } com.actionbarsherlock.view.MenuItem miBin = menu.add(this.getString(R.string.lblInitDalItem)); miBin.setShowAsAction(com.actionbarsherlock.view.MenuItem.SHOW_AS_ACTION_NEVER); miBin.setIcon(R.drawable.gd_action_bar_trashcan); miBin.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.titleReinitDalYesNo)); builder.setMessage( Html.fromHtml(GameSetHistoryActivity.this.getText(R.string.msgReinitDalYesNo).toString())); builder.setPositiveButton(GameSetHistoryActivity.this.getString(R.string.btnOk), GameSetHistoryActivity.this.removeAllGameSetsDialogClickListener); builder.setNegativeButton(GameSetHistoryActivity.this.getString(R.string.btnCancel), GameSetHistoryActivity.this.removeAllGameSetsDialogClickListener).show(); builder.setIcon(android.R.drawable.ic_dialog_alert); return true; } }); return true; }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); View view = findCurrentView(R.id.console_flip); final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final boolean activeTerminal = (view instanceof TerminalView); boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { TerminalBridge bridge = ((TerminalView) view).bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); }//from w w w. j a v a 2 s .c om menu.setQwertyMode(true); disconnect = menu.add(R.string.list_host_disconnect); if (hardKeyboard) disconnect.setAlphabeticShortcut('w'); if (!sessionOpen && disconnected) disconnect.setTitle(R.string.console_menu_close); disconnect.setEnabled(activeTerminal); disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel); disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); if (bound != null && prefs.getBoolean("unloadKeysOnDisconnect", true)) { bound.lockUnusedKeys(); } return true; } }); copy = menu.add(R.string.console_menu_copy); if (hardKeyboard) copy.setAlphabeticShortcut('c'); copy.setIcon(android.R.drawable.ic_menu_set_as); copy.setEnabled(activeTerminal); copy.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // mark as copying and reset any previous bounds TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); copySource = terminalView.bridge; SelectionArea area = copySource.getSelectionArea(); area.reset(); area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); area.setRow(copySource.buffer.getCursorRow()); area.setColumn(copySource.buffer.getCursorColumn()); copySource.setSelectingForCopy(true); // Make sure we show the initial selection copySource.redraw(); Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG) .show(); return true; } }); paste = menu.add(R.string.console_menu_paste); if (hardKeyboard) paste.setAlphabeticShortcut('v'); paste.setIcon(android.R.drawable.ic_menu_edit); paste.setEnabled(clipboard.hasText() && sessionOpen); paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // force insert of clipboard text into current console TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force // down String clip = clipboard.getText().toString(); bridge.injectString(clip); return true; } }); portForward = menu.add(R.string.console_menu_portforwards); if (hardKeyboard) portForward.setAlphabeticShortcut('f'); portForward.setIcon(android.R.drawable.ic_menu_manage); portForward.setEnabled(sessionOpen && canForwardPorts); portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT); return true; } }); urlscan = menu.add(R.string.console_menu_urlscan); if (hardKeyboard) urlscan.setAlphabeticShortcut('u'); urlscan.setIcon(android.R.drawable.ic_menu_search); urlscan.setEnabled(activeTerminal); urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminal = (TerminalView) findCurrentView(R.id.console_flip); TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.urlScan(terminal); return true; } }); resize = menu.add(R.string.console_menu_resize); if (hardKeyboard) resize.setAlphabeticShortcut('s'); resize.setIcon(android.R.drawable.ic_menu_crop); resize.setEnabled(sessionOpen); resize.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); ((EditText) resizeView.findViewById(R.id.width)) .setText(prefs.getString("default_fsize_width", "80")); ((EditText) resizeView.findViewById(R.id.height)) .setText(prefs.getString("default_fsize_height", "25")); new AlertDialog.Builder(ConsoleActivity.this).setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } if (width > 0 && height > 0) { terminalView.forceSize(width, height); terminalView.bridge.parentChanged(terminalView); } else { new AlertDialog.Builder(ConsoleActivity.this) .setMessage("Width and height must be higher than zero.") .setTitle("Error").show(); } } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } }); MenuItem ctrlKey = menu.add("Ctrl"); ctrlKey.setEnabled(activeTerminal); ctrlKey.setIcon(R.drawable.button_ctrl); MenuItemCompat.setShowAsAction(ctrlKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); ctrlKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.metaPress(TerminalKeyListener.META_CTRL_ON); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem escKey = menu.add("Esc"); escKey.setEnabled(activeTerminal); escKey.setIcon(R.drawable.button_esc); MenuItemCompat.setShowAsAction(escKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); escKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.sendEscape(); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem symKey = menu.add("SYM"); symKey.setEnabled(activeTerminal); symKey.setIcon(R.drawable.button_sym); MenuItemCompat.setShowAsAction(symKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); symKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.showCharPickerDialog(terminal); return true; } }); MenuItem inputButton = menu.add("Input"); inputButton.setEnabled(activeTerminal); inputButton.setIcon(R.drawable.button_input); MenuItemCompat.setShowAsAction(inputButton, MenuItem.SHOW_AS_ACTION_IF_ROOM); inputButton.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); return true; } }); MenuItem keyboard = menu.add("Show Keyboard"); keyboard.setEnabled(activeTerminal); keyboard.setIcon(R.drawable.button_keyboard); MenuItemCompat.setShowAsAction(keyboard, MenuItem.SHOW_AS_ACTION_IF_ROOM); keyboard.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); return true; } }); MenuItem keys = menu.add(R.string.console_menu_pubkeys); keys.setIcon(android.R.drawable.ic_lock_lock); keys.setIntent(new Intent(this, PubkeyListActivity.class)); keys.setEnabled(activeTerminal); keys.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ConsoleActivity.this, PubkeyListActivity.class); intent.putExtra(PubkeyListActivity.PICK_MODE, true); ConsoleActivity.this.startActivityForResult(intent, REQUEST_SELECT); return true; } }); return true; }
From source file:net.ddns.mlsoftlaberge.mlsoft.contacts.ContactsListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Sends a request to the People app to display the create contact screen case R.id.menu_add_contact: final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); startActivity(intent);/*ww w .jav a2 s . co m*/ break; // For platforms earlier than Android 3.0, triggers the search activity case R.id.menu_search: if (!Utils.hasHoneycomb()) { getActivity().onSearchRequested(); } break; // Sends a request to the People app to display the create contact screen case R.id.menu_starred: // switch the starred flag on/off if (starredfind == 0) { starredfind = 1; item.setIcon(R.drawable.btn_star_big_on); } else { starredfind = 0; item.setIcon(R.drawable.btn_star_big_off); } // reread the list with new flag getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, ContactsListFragment.this); break; } return super.onOptionsItemSelected(item); }