List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:org.intermine.app.activity.MainActivity.java
private void setupDrawerLayout() { mMainMenuDisplayed = true;/*from w ww.ja va 2s .co m*/ mDrawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerClosed(View drawerView) { if (mMainMenuDisplayed) { if (R.id.drawer_settings == mLastSelectedMenuItem) { Intent intent = new Intent(MainActivity.this, SettingsActivity.class); startActivity(intent); mLastSelectedMenuItem = -1; } else if (R.id.drawer_login == mLastSelectedMenuItem) { Intent intent = new Intent(MainActivity.this, LoginActivity.class); startActivityForResult(intent, LOGIN_ACTIVITY_CODE); mLastSelectedMenuItem = -1; } else if (R.id.drawer_logout == mLastSelectedMenuItem) { getStorage().setUserToken(mMineName, null); Menu menu = mNavigationView.getMenu(); menu.findItem(R.id.drawer_login).setVisible(true); menu.findItem(R.id.drawer_logout).setVisible(false); updateNavigationView(); mLastSelectedMenuItem = -1; } } } } ); mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (mMainMenuDisplayed) { populateMainContent(menuItem.getItemId()); mLastSelectedMenuItem = menuItem.getItemId(); } else { mMineName = menuItem.getTitle().toString(); getStorage().setWorkingMineName(mMineName); mMineNameView.setText(mMineName); updateLoginState(); if (menuItem.getItemId() != R.id.drawer_settings && menuItem.getItemId() != R.id.drawer_login && menuItem.getItemId() != R.id.drawer_logout) { populateMainContent(mLastSelectedMenuItem); } } mDrawerLayout.closeDrawers(); return true; } } ); }
From source file:org.yaoha.YaohaActivity.java
public boolean editFavs(MenuItem item, final ImageButton btn, final TextView tv) { if (item.getTitle() == EDIT_FAV_STRING) { openFavMenu(btn, tv);/* w ww.j a va 2s .c o m*/ } else if (item.getTitle() == EDIT_FAV_PIC) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); actualButton = btn; //workaround, there must be a better way startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); } else if (item.getTitle() == REMOVE_FAV) { tv.setText(getText(R.string.add_favorite)); btn.setImageResource(R.drawable.plus_sign_small); String tmp = ""; final Editor edit = prefs.edit(); if (btn.getId() == button_favorite_1.getId()) { tmp = "saved_fav_1_text"; } else if (btn.getId() == button_favorite_2.getId()) { tmp = "saved_fav_2_text"; } else if (btn.getId() == button_favorite_3.getId()) { tmp = "saved_fav_3_text"; } else if (btn.getId() == button_favorite_4.getId()) { tmp = "saved_fav_4_text"; } else if (btn.getId() == button_favorite_5.getId()) { tmp = "saved_fav_5_text"; } else if (btn.getId() == button_favorite_6.getId()) { tmp = "saved_fav_6_text"; } edit.remove(tmp); edit.commit(); } else { Toast.makeText(this, "Placeholder - You schould never see this.", Toast.LENGTH_SHORT).show(); return false; } return super.onContextItemSelected(item); }
From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java
private void onMenuItemSelected(MenuItem menuItem) { if (controller.getActivity() == null) { return;//from w w w. ja va2 s . co m } checkedNavViewMenuItemId = menuItem.getItemId(); Engine.instance().getVibrator().hapticFeedback(); controller.syncNavigationMenu(); menuItem.setChecked(true); controller.setTitle(menuItem.getTitle()); int menuActionId = menuItem.getItemId(); Fragment fragment = controller.getFragmentByNavMenuId(menuItem.getItemId()); if (fragment != null) { controller.switchContent(fragment); } else { switch (menuActionId) { case R.id.menu_main_my_music: controller.launchMyMusic(); break; case R.id.menu_main_library: controller.showMyFiles(); break; case R.id.menu_main_transfers: controller.showTransfers(TransfersFragment.TransferStatus.ALL); break; case R.id.menu_main_support: UIUtils.openURL(controller.getActivity(), Constants.SUPPORT_URL); break; case R.id.menu_main_settings: controller.showPreferences(); break; case R.id.menu_main_shutdown: controller.showShutdownDialog(); break; default: break; } } hide(); if ((menuActionId == R.id.menu_main_my_music || menuActionId == R.id.menu_main_search || menuActionId == R.id.menu_main_library) && controller.getActivity() != null) { Offers.showInterstitialOfferIfNecessary(controller.getActivity(), Offers.PLACEMENT_INTERSTITIAL_MAIN, false, false, true); } }
From source file:com.theultimatelabs.scale.ScaleActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, String.format("item selected %s", item.getTitle())); return true;/*w ww. j av a 2s.c o m*/ }
From source file:org.codecyprus.android_client.ui.ActivityCurrentQuestion.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish();/* w w w. ja v a2s . c om*/ return true; } else if (getString(R.string.SKIP).equals(item.getTitle())) { final DialogSkip dialogSkip = new DialogSkip(this); dialogSkip.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dialogSkip.isSkip()) { skipQuestion(); } } }); dialogSkip.show(); return true; } else if (getString(R.string.Score_board).equals(item.getTitle())) { showScoreBoard(); return true; } else { return super.onOptionsItemSelected(item); } }
From source file:com.uele.examples.loginviewsmvp.mvp.view.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initializePresenter();/* www. j a v a 2 s. c om*/ mainPresenter.onCreate(savedInstanceState); LayoutInflater inflater = getLayoutInflater(); drawerLayout.setStatusBarBackgroundColor(statusBarColor); drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); drawer.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.nav_settings: Toast.makeText(MainActivity.this, "Search!", LENGTH_SHORT).show(); break; case R.id.nav_feedback: Toast.makeText(MainActivity.this, "Trending!", LENGTH_SHORT).show(); break; default: throw new IllegalStateException("Unknown navigation item: " + item.getTitle()); } drawerLayout.closeDrawers(); // If we supported actual navigation, we would change what was checked and navigate there. //item.setChecked(true); return true; } }); // inflater.inflate(R.layout.main_view, content); }
From source file:org.gdg.frisbee.android.common.GdgNavDrawerActivity.java
private void onDrawerSpecialItemClick(MenuItem item, Bundle data) { // If title is null them we are not in a SpecialEventActivity if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null && getSupportActionBar().getTitle().equals(item.getTitle())) { return;/*from w w w . ja v a 2 s . c o m*/ } final ArrayList<TaggedEventSeries> currentEventSeries = App.getInstance().currentTaggedEventSeries(); for (TaggedEventSeries taggedEventSeries : currentEventSeries) { if (taggedEventSeries.getDrawerId() == item.getItemId()) { data.putString(Const.EXTRA_TAGGED_EVENT_CACHEKEY, taggedEventSeries.getTag()); data.putParcelable(Const.EXTRA_TAGGED_EVENT, taggedEventSeries); navigateTo(TaggedEventSeriesActivity.class, data); break; } } }
From source file:com.microsoft.azure.engagement.MainActivity.java
/** * Method that replaces the current fragment * * @param item The new menu item selected * @param fragmentClass The new fragment class *//* w w w . j a v a 2 s. c om*/ private final void replaceFragment(MenuItem item, @NonNull Class<? extends Fragment> fragmentClass) { // Hide the in-app layout if it's visible hideNotificationOverlay(); updateSelection(item); try { final Fragment fragment = fragmentClass.newInstance(); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(item.getTitle()); getSupportActionBar().setDisplayShowTitleEnabled(fragment instanceof HomeFragment == false); } final String backStateName = fragment.getClass().getName(); final FragmentManager fragmentManager = getSupportFragmentManager(); final boolean fragmentPopped = fragmentManager.popBackStackImmediate(backStateName, 0); if (fragmentPopped == false) { //fragment not in back stack, create it. final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fragmentPlaceHolder, fragment); fragmentTransaction.addToBackStack(backStateName); fragmentTransaction.commit(); } } catch (Exception exception) { Log.e(MainActivity.TAG, "Unable to instantiate the fragment with class '" + fragmentClass.getSimpleName() + "'"); } }
From source file:de.k3b.android.toGoZip.SettingsActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.cmd_send: return onCmdSend(item.getTitle()); case R.id.cmd_delete: return onCmdDeleteQuestion(); case R.id.cmd_view_zip: return onShowZip(); case R.id.cmd_filemanager: ZipStorage storage = SettingsImpl.getCurrentZipStorage(this); return FileManagerUtil.showInFilemanager(this, getZipFolder(storage)); case R.id.cmd_about: AboutDialogPreference.createAboutDialog(this).show(); return true; }//from www . j a v a2 s .c o m return super.onOptionsItemSelected(item); }
From source file:com.github.kanata3249.ffxieq.android.FoodSelectorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { FoodListView flv = (FoodListView) findViewById(R.id.ListView); if (item.getGroupId() == R.id.FilterByType) { if (item.getItemId() < 0) { mFilterByType = ""; } else {/*from w w w . ja va 2 s . c o m*/ mFilterByType = (String) item.getTitle(); } flv.setFilterByType(mFilterByType); return true; } switch (item.getItemId()) { case R.id.Remove: Intent result = new Intent(); result.putExtra("From", "FoodSelector"); result.putExtra("Id", -1); setResult(RESULT_OK, result); finish(); return true; case R.id.Filter: showDialog(0); return true; case R.id.ResetFilter: if (flv != null) { flv.setFilter(""); } mFilterID = -1; return true; default: return super.onOptionsItemSelected(item); } }