@Override public boolean onContextItemSelected(MenuItem item) { for (int i = 0; i < listOfCoun.size(); i++) { if (item.getTitle() == listOfCoun.get(i)) { setCoun = listOfCoun.get(i); setText(listOfCoun.get(i), "tcoun"); return true; } } for (int i = 0; i < listOfProv.size(); i++) { if (item.getTitle() == listOfProv.get(i)) { setProv = listOfProv.get(i); setText(listOfProv.get(i), "tprov"); return true; } } for (int i = 0; i < listOfCity.size(); i++) { if (item.getTitle() == listOfCity.get(i)) { setCity = listOfCity.get(i); setText(listOfCity.get(i), "tcity"); return true; } } return true; }
public boolean onContextItemSelected(MenuItem item) { if (data.tournaments.get(menuItemSelected).getFinished() && item.getTitle() == "Standings") { Intent intent = new Intent(getApplicationContext(), Ranking.class); // Application Context and Activity intent.putExtra("tournament", menuItemSelected); startActivityForResult(intent, 0); } else { if (item.getTitle() == "Edit") { if (!data.tournaments.get(menuItemSelected).tournamentStarted) { Intent intent = new Intent( getApplicationContext(), EditTournament.class); // Application Context and Activity intent.putExtra("tournament", menuItemSelected); startActivityForResult(intent, 0); } else { Toast.makeText( getApplicationContext(), "Cannot edit tournament in progress", Toast.LENGTH_LONG) .show(); } } } if (item.getTitle() == "Delete") { int position = menuItemSelected; String name = data.tournaments.get(position).toString().concat(" removed!"); data.tournaments.remove(position); listAdapter.notifyDataSetChanged(); Toast.makeText(getApplicationContext(), name, Toast.LENGTH_LONG).show(); } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (Logging.DEBUG) Log.d(Logging.TAG, "BOINCActivity onOptionsItemSelected()"); // toggle drawer if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } switch (item.getItemId()) { case R.id.run_mode: if (item.getTitle().equals(getApplication().getString(R.string.menu_run_mode_disable))) { if (Logging.DEBUG) Log.d(Logging.TAG, "run mode: disable"); new WriteClientModeAsync().execute(BOINCDefs.RUN_MODE_NEVER); } else if (item.getTitle() .equals(getApplication().getString(R.string.menu_run_mode_enable))) { if (Logging.DEBUG) Log.d(Logging.TAG, "run mode: enable"); new WriteClientModeAsync().execute(BOINCDefs.RUN_MODE_AUTO); } else if (Logging.DEBUG) Log.d(Logging.TAG, "run mode: unrecognized command"); return true; case R.id.projects_add: startActivity(new Intent(this, SelectionListActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement switch (item.getItemId()) { case R.id.action_settings: Log.i(TAG, "Menu item: " + item.getTitle()); return true; case R.id.action_settings_sound: Log.i(TAG, "Menu item: " + item.getTitle()); Intent sound_intent = new Intent(this, SoundSettingsActivity.class); startActivityForResult(sound_intent, REQUEST_CODE); return true; case R.id.action_settings_ble: Log.i(TAG, "Menu item: " + item.getTitle()); Intent ble_intent = new Intent(this, BLESettingsActivity.class); startActivity(ble_intent); return true; case R.id.action_settings_sensitivity: Log.i(TAG, "Menu item: " + item.getTitle()); Intent sensitivity_intent = new Intent(this, SensitivitySettingsActivity.class); startActivity(sensitivity_intent); return true; default: return super.onOptionsItemSelected(item); } }
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getTitle() == "Move") { moveDialog(); } if (item.getTitle() == "Rename") { renameDialog(); } if (item.getTitle() == "Set Description") { descriptionDialog(); } if (item.getTitle() == "Upload Track to Dropbox") { Toast.makeText( ActivityTracksListView.this, "Upload " + selected.getTrackName() + " to Dropbox", Toast.LENGTH_SHORT) .show(); if (dropboxAuthentication()) { uploadToDropbox(); } } if (item.getTitle() == "Delete") { deleteDialog(); } return false; }
/** Creates and returns a menu button for the specified menu item. */ private static Button createMenuItemButton(Context context, MenuItem menuItem) { Button menuItemButton = (Button) LayoutInflater.from(context).inflate(R.layout.floating_popup_menu_button, null); menuItemButton.setText(menuItem.getTitle()); menuItemButton.setContentDescription(menuItem.getTitle()); return menuItemButton; }
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { Toast toast = null; ArrayList<ItemTO> selectedListItems = new ArrayList<>(); StringBuilder selectedItems = new StringBuilder(); // get items selected for (ItemTO i : listItens) { if (i.getChecked()) { selectedListItems.add(i); selectedItems.append(i.getDescricao()).append(", "); } } if (item.getTitle().equals("Move")) { toast = Toast.makeText(getActivity(), "Move: " + selectedItems.toString(), Toast.LENGTH_SHORT); } else if (item.getTitle().equals("Remove star")) { toast = Toast.makeText( getActivity(), "Remove star: " + selectedItems.toString(), Toast.LENGTH_SHORT); } if (toast != null) { toast.show(); } finishMultiAction(); mMode.finish(); return true; }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); String number = phoneNo; try { // number=new ContactListAdapter(this).numberList.get(info.position); if (item.getTitle() == "Call") { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + number)); startActivity(callIntent); } else if (item.getTitle() == "Send SMS") { Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setType("vnd.android-dir/mms-sms"); smsIntent.putExtra("address", number); startActivity(smsIntent); } else { return false; } return true; } catch (Exception e) { return true; } }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (menuEnabled && menuResetItem != null && menuResetItem.getTitle().equals(item.getTitle())) { connection.reset(); return true; // connection only needs to reset once } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } if (item.getItemId() == R.id.settings) { startActivity(new Intent(this, Prefs.class)); return true; } if (item.getTitle().toString().contains("Sort by")) { if (sortDir.equals("DESC")) { sortDir = "ASC"; } else { sortDir = "DESC"; } } if (item.getTitle().toString().equals("Sort by Title")) { sortStr = "title"; try { populateMyMovies(lv); } catch (ParseException e) { e.printStackTrace(); } return true; } if (item.getTitle().toString().equals("Sort by Rating")) { sortStr = "rating"; try { populateMyMovies(lv); } catch (ParseException e) { e.printStackTrace(); } return true; } if (item.getTitle().toString().equals("Sort by Theater")) { sortStr = "theater_id"; try { populateMyMovies(lv); } catch (ParseException e) { e.printStackTrace(); } return true; } switch (item.getItemId()) { case android.R.id.home: return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.d(TAG, "onOptionItemSelected"); if (item.getTitle() == "Simulate") { showControls(); } else if (item.getTitle() == "Quit") { finish(); System.exit(0); } return true; }
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getTitle() == "Random") { uploadRandom(); } else if (item.getTitle() == "Choose friend") { Intent intent = new Intent(SendPhotoActivity.this, ChooseFriendActivity.class); startActivityForResult(intent, 100); } else { return false; } return true; }
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case MENU_ADD: Toast.makeText(this, item.getTitle() + "__menu", 0).show(); return true; case MENU_UPDATE: Toast.makeText(this, item.getTitle() + "__menu", 0).show(); return true; default: return super.onMenuItemSelected(featureId, item); } }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); final TrackedEntityInstanceItemRow itemRow = (TrackedEntityInstanceItemRow) mListView.getItemAtPosition(info.position); Log.d(TAG, "" + itemRow.getTrackedEntityInstance().getTrackedEntityInstance()); if (item.getTitle() .toString() .equals( getResources() .getString(org.hisp.dhis.android.sdk.R.string.go_to_programoverview_fragment))) { mNavigationHandler.switchFragment( ProgramOverviewFragment.newInstance( mState.getOrgUnitId(), mState.getProgramId(), itemRow.getTrackedEntityInstance().getLocalId()), TAG, true); } else if (item.getTitle() .toString() .equals(getResources().getString(org.hisp.dhis.android.sdk.R.string.delete))) { if (!(itemRow .getStatus() .equals(OnRowClick.ITEM_STATUS.SENT))) // if not sent to server, present dialog to user { UiUtils.showConfirmDialog( getActivity(), getActivity().getString(R.string.confirm), getActivity().getString(R.string.warning_delete_unsent_tei), getActivity().getString(R.string.delete), getActivity().getString(R.string.cancel), (R.drawable.ic_event_error), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { performSoftDeleteOfTrackedEntityInstance(itemRow.getTrackedEntityInstance()); dialog.dismiss(); } }); } else { // if sent to server, be able to soft delete without annoying the user performSoftDeleteOfTrackedEntityInstance(itemRow.getTrackedEntityInstance()); } } return true; }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getTitle().equals("Play")) { Recording recording = Recording.getRecordings().get(info.position); recording.play(); } if (item.getTitle().equals("Delete")) { Recording recording = Recording.getRecordings().get(info.position); recording.delete(this); showRecordings(); } return true; }
@Override public boolean onContextItemSelected(MenuItem item) { Log.d( TAG, "Selected position = " + selectedPosition + " and title = " + item.getTitle().toString()); if (item.getTitle().equals("Delete Car")) { cars.get(selectedPosition).delete(); resetCarList(); } else { return false; } return true; }
@Test public void add_AddsItemsInOrder() { MyActivity activity = new MyActivity(); TestMenu testMenu = new TestMenu(activity); testMenu.add(0, 0, 1, "greeting"); testMenu.add(0, 0, 0, "hell0"); testMenu.add(0, 0, 0, "hello"); MenuItem item = testMenu.getItem(0); assertEquals("hell0", item.getTitle()); item = testMenu.getItem(1); assertEquals("hello", item.getTitle()); item = testMenu.getItem(2); assertEquals("greeting", item.getTitle()); }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); final ViewGroup characterItemView = (ViewGroup) info.targetView; // info.position will give the index of selected item if (item.getTitle() == "Copy") { final String characterName = ((TextView) characterItemView.findViewById(R.id.list_character_name)) .getText() .toString(); NewCharacterDialog(this, characterName); } else if (item.getTitle() == "Delete") { final CharacterListAdapter abc = characterListAdapter; // Code to execute when clicked on This Item // find the list object // get the name of the character in that object TextView charName = (TextView) (characterItemView.getChildAt(0)); String name = String.valueOf(charName.getText()); File a = new File(getApplicationContext().getFilesDir().getAbsolutePath() + "/" + name + ".chr"); if (a.delete()) { Toast.makeText(getApplicationContext(), name + " deleted.", Toast.LENGTH_SHORT).show(); abc.removeView(name); GenerateCharacterButtons(); } else { Toast.makeText( getApplicationContext(), name + " not deleted, please try again.", Toast.LENGTH_SHORT) .show(); } } else { return false; } return true; }
private List<CharSequence> getMenuItemTitles(List<MenuItem> menuItems) { List<CharSequence> titles = new ArrayList<CharSequence>(); for (MenuItem menuItem : menuItems) { titles.add(menuItem.getTitle()); } return titles; }
@Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.nav_new: break; case R.id.nav_xingan: break; case R.id.nav_mr: break; case R.id.nav_sw: break; case R.id.nav_xz: break; case R.id.nav_wallpaper: break; case R.id.nav_share: break; case R.id.nav_personal: break; } toolbar.setTitle(item.getTitle()); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
@Override public void onPrepareOptionsMenu(final Menu menu) { BlobDescriptorList list = getDescriptorList(); miFilter = menu.findItem(R.id.action_filter); miFilter.setIcon(icFilter); View filterActionView = miFilter.getActionView(); SearchView searchView = (SearchView) filterActionView.findViewById(R.id.fldFilter); searchView.setQueryHint(miFilter.getTitle()); searchView.setQuery(list.getFilter(), true); searchView.setOnQueryTextListener( new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return true; } @Override public boolean onQueryTextChange(String newText) { BlobDescriptorList list = getDescriptorList(); if (!newText.equals(list.getFilter())) { getDescriptorList().setFilter(newText); } return true; } }); setSortOrder(menu.findItem(R.id.action_sort_order), list.getSortOrder()); setAscending(menu.findItem(R.id.action_sort_asc), list.isAscending()); super.onPrepareOptionsMenu(menu); }
/** Called when one of the menu items is selected. */ public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); Utilities.LogInfo("Option item selected - " + String.valueOf(item.getTitle())); switch (itemId) { case R.id.mnuSettings: Intent settingsActivity = new Intent(getApplicationContext(), GpsSettingsActivity.class); startActivity(settingsActivity); break; case R.id.mnuOSM: UploadToOpenStreetMap(); break; case R.id.mnuDropBox: UploadToDropBox(); break; case R.id.mnuAnnotate: Annotate(); break; case R.id.mnuShare: Share(); break; case R.id.mnuEmailnow: EmailNow(); break; case R.id.mnuExit: loggingService.StopLogging(); loggingService.stopSelf(); finish(); break; } return false; }
@Override public boolean onOptionsItemSelected(MenuItem item) { try { int id = item.getItemId(); CharSequence itemTitle = item.getTitle(); // Esto podria ser un enum de item menu que correspondan a otro menu if (itemTitle.equals("New Identity")) { changeActivity(Activities.CWP_INTRA_USER_CREATE_ACTIVITY.getCode()); } // if(id == R.id.action_connection_request){ // Toast.makeText(getActivity(),"Intra user // request",Toast.LENGTH_SHORT).show(); // } if (item.getItemId() == R.id.action_notifications) { changeActivity(Activities.CCP_SUB_APP_INTRA_USER_COMMUNITY_REQUEST.getCode()); return true; } } catch (Exception e) { errorManager.reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, FermatException.wrapException(e)); makeText(getActivity(), "Oooops! recovering from system error", LENGTH_LONG).show(); } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case MENU_ADD: Toast.makeText(this, item.getTitle(), 0).show(); return true; case MENU_UPDATE: Toast.makeText(this, item.getTitle(), 0).show(); return true; default: return super.onOptionsItemSelected(item); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // évènement appelé lorsqu'un menu est choisi switch (item.getItemId()) { // l'identifiant integer est moins gourmand en ressource que le // string case 2001: Toast.makeText(this, "Paramètres", 1000).show(); Intent intentParametres = new Intent(this, tab_param.class); intentParametres.putExtra(ActivityParam.LaunchFromRechercheProduitPerime, true); // on demarre la nouvelle activité startActivity(intentParametres); termineActivity(); break; case 2002: Toast.makeText(this, "Notes", 1000).show(); Intent intentNote = new Intent(this, note_page1.class); // on demarre la nouvelle activité startActivity(intentNote); termineActivity(); break; case 2003: AlertDialog.Builder adHelp = new AlertDialog.Builder(this); adHelp.setTitle("Aide"); adHelp.setIcon(R.drawable.ad_question); adHelp.setMessage( "En cliquant sur un produit vous pourrez afficher le détail de celui-ci ou le copier dans une nouvelle note.\n" + "En appuyant longtemps sur un produit, vous pourrez le supprimer.\n"); adHelp.setPositiveButton("Ok", null); adHelp.show(); } Log.i("", "" + item.getTitle()); return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection Log.d(TAG, "Menu item selected: " + item.getTitle()); final int itemId = item.getItemId(); checkAdminPermission( itemId, new AdminSecurityManager.AuthListener() { public void onPermissionGranted() { if (itemId == R.id.menu_download) { startActivity(new Intent(OppiaMobileActivity.this, TagSelectActivity.class)); } else if (itemId == R.id.menu_about) { startActivity(new Intent(OppiaMobileActivity.this, AboutActivity.class)); } else if (itemId == R.id.menu_monitor) { startActivity(new Intent(OppiaMobileActivity.this, MonitorActivity.class)); } else if (itemId == R.id.menu_scorecard) { startActivity(new Intent(OppiaMobileActivity.this, ScorecardActivity.class)); } else if (itemId == R.id.menu_search) { startActivity(new Intent(OppiaMobileActivity.this, SearchActivity.class)); } else if (itemId == R.id.menu_settings) { startPrefsActivity(); } else if (itemId == R.id.menu_language) { createLanguageDialog(); } else if (itemId == R.id.menu_logout) { logout(); } } }); return true; }
public boolean onMenuItemClick(MenuItem item) { if (item.getTitle().equals("Beenden") || item.getTitle().equals("close")) { AlertDialog.Builder dialog = dc.getBeendenBuilder(this, KontoControl.getSPRACHE()); dialog.show(); } if (item.getTitle().equals("english")) { KontoControl.setSPRACHE("english"); startActivity(getIntent()); } if (item.getTitle().equals("deutsch")) { KontoControl.setSPRACHE("deutsch"); startActivity(getIntent()); } return false; }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); String itemName = (String) item.getTitle(); int index = info.position; if (itemName.equals(mTangoSpaceMenuStrings[0])) { // Delete the ADF from Tango space and update the Tango ADF Listview. showSetNameDialog(mTangoSpaceAdfDataList.get(index).uuid); } else if (itemName.equals(mTangoSpaceMenuStrings[1])) { // Delete the ADF from Tango space and update the Tango ADF Listview. deleteAdfFromTangoSpace(mTangoSpaceAdfDataList.get(index).uuid); } else if (itemName.equals(mTangoSpaceMenuStrings[2])) { // Export the ADF into application package folder and update the Listview. exportAdf(mTangoSpaceAdfDataList.get(index).uuid); } else if (itemName.equals(mAppSpaceMenuStrings[0])) { // Delete an ADF from App space and update the App space ADF Listview. deleteAdfFromAppSpace(mAppSpaceAdfDataList.get(index).uuid); } else if (itemName.equals(mAppSpaceMenuStrings[1])) { // Import an ADF from app space to Tango space. importAdf(mAppSpaceAdfDataList.get(index).uuid); } updateList(); return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().toString().equals(refreshDate)) { // 初始化数据,这里模拟网络获取数据 PictureData pictureData = initData(); mAdapter.setItemLists(pictureData.pictures); // 数据适配器设置数据 mWrapAdapter.notifyDataSetChanged(); // 包装类适配器刷新数据 } else if (item.getTitle().toString().equals(addHeader)) { addHeaderView(); } else if (item.getTitle().toString().equals(addFooter)) { addFooterView(); } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Log.i(TAG,"Here in selected click"); switch (item.getItemId()) { case 1: Log.i(TAG, "you clicked on item " + item.getTitle()); return true; case 2: Log.i(TAG, "you clicked on item " + item.getTitle()); return true; case 3: Log.i(TAG, "you clicked on item " + item.getTitle()); return true; } return super.onOptionsItemSelected(item); }