List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:fragments.LogPagerFragment.java
/** * Process the selected iot_menu item.// w w w. j a v a 2 s.c o m * @param item The selected iot_menu item. * @return true in all cases. */ @Override public boolean onOptionsItemSelected(MenuItem item) { Log.d(TAG, ".onOptionsItemSelected() entered"); // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_profiles: return true; case R.id.action_tutorial: openTutorial(); return true; case R.id.action_web: openWeb(); return true; case R.id.action_accel: app.toggleAccel(); return true; case R.id.clear: app.setUnreadCount(0); app.getMessageLog().clear(); listAdapter.notifyDataSetInvalidated(); return true; case R.id.action_clear_profiles: app.clearProfiles(); return true; default: if (item.getTitle().equals(getResources().getString(R.string.app_name))) { getActivity().openOptionsMenu(); return true; } else { return super.onOptionsItemSelected(item); } } }
From source file:com.frostwire.android.gui.activities.MainActivity.java
private void updateHeader(Fragment fragment) { try {/*from w w w .ja va 2 s .c o m*/ Toolbar toolbar = findToolbar(); if (toolbar == null) { LOG.warn("updateHeader(): Check your logic, no actionBar available"); return; } if (fragment instanceof MainFragment) { View header = ((MainFragment) fragment).getHeader(this); if (header != null) { setToolbarView(header); } } if (navigationMenu != null) { MenuItem item = navigationMenu.getCheckedItem(); setTitle(item.getTitle()); } } catch (Throwable e) { LOG.error("Error updating main header", e); } }
From source file:me.albertonicoletti.latex.activities.EditorActivity.java
/** * Initializes the symbols shortcut bar. *///from ww w .ja va 2s . com private void initSymbols() { // It actually only initializes the "+" button, creating a popup menu final Button button = (Button) findViewById(R.id.maths_button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Shows a popup menu PopupMenu popup = new PopupMenu(EditorActivity.this, button); popup.getMenuInflater().inflate(R.menu.menu_maths, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { // On symbol click insertSymbol(menuItem.getTitle().toString()); return false; } }); popup.show(); } }); }
From source file:com.example.shyam.popi.LearnEmotions.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Navigate "up" the demo structure to the launchpad activity. // See http://developer.android.com/design/patterns/navigation.html for more. NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class)); return true; case R.id.action_previous: // Go to the previous step in the wizard. If there is no previous step, // setCurrentItem will do nothing. mPager.setCurrentItem(mPager.getCurrentItem() - 1); return true; case R.id.action_next: // Advance to the next step in the wizard. If there is no next step, setCurrentItem // will do nothing. if (item.getTitle() == getResources().getString(R.string.action_finish)) { Toast.makeText(getApplicationContext(), "You are finished", Toast.LENGTH_SHORT).show(); new Handler().postDelayed(new Runnable() { @Override/*from w w w . j a v a 2s . c o m*/ public void run() { NavUtils.navigateUpTo(LearnEmotions.this, new Intent(LearnEmotions.this, MainActivity.class)); } }, 3000); } mPager.setCurrentItem(mPager.getCurrentItem() + 1); return true; } return super.onOptionsItemSelected(item); }
From source file:org.ale.scanner.zotero.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.ctx_manual: mAlertDialog = Dialogs.showManualEntryDialog(MainActivity.this); break;/*from w w w .jav a 2s. c om*/ case R.id.ctx_check_all: if (item.getTitle().equals(getString(R.string.uncheck_all))) { // Uncheck All mItemAdapter.setChecked(new int[0]); } else { // Check All int[] all = new int[mItemAdapter.getGroupCount()]; for (int i = 0; i < all.length; i++) all[i] = i; mItemAdapter.setChecked(all); } mItemAdapter.notifyDataSetChanged(); break; case R.id.ctx_library: mAlertDialog = Dialogs.showSelectLibraryDialog(MainActivity.this, mGroups, mSelectedGroup); break; case R.id.ctx_engine: mAlertDialog = Dialogs.showSearchEngineDialog(MainActivity.this, mISBNService); break; case R.id.ctx_logout: logout(); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:joshuatee.wx.USWarningsWithRadarActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getTitle().equals("Show radar products")) { RadarProdShow(item.getItemId()); } else if (item.getTitle().equals("Open radar interface")) { RadarInterface(item.getItemId()); } else if (item.getTitle().equals("Open radar mosaic")) { RadarMosaic(item.getItemId());// w w w .jav a 2 s . co m } else if (((String) item.getTitle()).contains("Add new location for this warning")) { LocationAdd(item.getItemId()); } else { return false; } return true; }
From source file:com.afg.MngProductContentProvider.Home_Activity.java
public void setupDrawerContent() { mNav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override//from www .jav a2s . c o m public boolean onNavigationItemSelected(@NonNull MenuItem item) { item.setChecked(true); switch (item.getItemId()) { case R.id.action_home: showHome(); break; case R.id.action_list: showList(); break; case R.id.pharmacy: showPharmacy(); break; case R.id.action_sales: showSales(); break; case R.id.category: showListCategories(); default: item.setChecked(false); break; } mDrawer.closeDrawer(GravityCompat.START); setTitle(item.getTitle()); return true; } }); }
From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java
private void restoreCards() { try {// w ww.ja va2 s . c o m ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); int start = 0; if (cardListView != null && cardListView.getAdapter() != null) start = cardListView.getAdapter().getCount(); if (cards == null) { cards = new ArrayList<Card>(); mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards); cardListView.setAdapter(mCardArrayAdapter); } for (int i = start; i < ids.size(); i++) { Card card = new Card(getActivity()); final CustomHeaderInnerCard header = new CustomHeaderInnerCard(getActivity()); header.setTitle(ids.get(i).getJSONObject().getString("title")); header.position = i; final ImagesFragment fragment = this; if (ids.get(i).getJSONObject().has("subreddit")) header.setPopupMenu(R.menu.card_image, new CardHeader.OnClickCardHeaderPopupMenuListener() { @Override public void onMenuItemClick(BaseCard card, MenuItem item) { ImgurHoloActivity imgurHoloActivity = (ImgurHoloActivity) getActivity(); if (item.getTitle().equals(getString(R.string.rating_good))) ImageUtils.upVote(fragment, ids.get(header.position), null, null, imgurHoloActivity.getApiCall()); if (item.getTitle().equals(getString(R.string.rating_bad))) ImageUtils.downVote(fragment, ids.get(header.position), null, null, imgurHoloActivity.getApiCall()); if (item.getTitle().equals(getString(R.string.account))) ImageUtils.gotoUser(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_share))) ImageUtils.shareImage(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_copy))) ImageUtils.copyImageURL(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_download))) ImageUtils.downloadImage(fragment, ids.get(header.position)); ImageUtils.updateImageFont(ids.get(header.position), header.scoreText); } }); else header.setPopupMenu(R.menu.card_image_no_account, new CardHeader.OnClickCardHeaderPopupMenuListener() { @Override public void onMenuItemClick(BaseCard card, MenuItem item) { ImgurHoloActivity imgurHoloActivity = (ImgurHoloActivity) getActivity(); if (item.getTitle().equals(getString(R.string.rating_good))) ImageUtils.upVote(fragment, ids.get(header.position), null, null, imgurHoloActivity.getApiCall()); if (item.getTitle().equals(getString(R.string.rating_bad))) ImageUtils.downVote(fragment, ids.get(header.position), null, null, imgurHoloActivity.getApiCall()); if (item.getTitle().equals(getString(R.string.account))) ImageUtils.gotoUser(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_share))) ImageUtils.shareImage(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_copy))) ImageUtils.copyImageURL(fragment, ids.get(header.position)); if (item.getTitle().equals(getString(R.string.action_download))) ImageUtils.downloadImage(fragment, ids.get(header.position)); ImageUtils.updateImageFont(ids.get(header.position), header.scoreText); } }); card.addCardHeader(header); CustomThumbCard thumb = new CustomThumbCard(getActivity()); thumb.setHeader(header); thumb.setExternalUsage(true); thumb.position = i; final int position = i; card.addCardThumbnail(thumb); if (!activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT) .equals(MainActivity.HOLO_LIGHT)) card.setBackgroundResourceId(R.drawable.dark_card_background); CardView cardView = (CardView) getActivity().findViewById(R.id.list_cardId); card.setCardView(cardView); card.setOnClickListener(new Card.OnCardClickListener() { @Override public void onClick(Card card, View view) { selectItem(position); } }); cards.add(card); } mCardArrayAdapter.notifyDataSetChanged(); } catch (JSONException e) { Log.e("Error!", e.toString()); } }
From source file:com.example.angelina.travelapp.map.MapFragment.java
/** * When activity first starts, the action bar * shows the back arrow for navigating back * to parent activity. Menu item click listener * responds in one of the following ways: * 1) navigating back to list of places, * 2) showing the filter UI//from w w w. j a v a 2 s .c o m * 3) showing the route to selected place in map */ private void setUpToolbar() { final Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.map_toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); toolbar.setTitle(""); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); ab.setHomeAsUpIndicator(0); // Use default home icon } // Menu items change depending on presence/absence of bottom sheet toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { if (item.getTitle().toString().equalsIgnoreCase(getString(R.string.list_view))) { // Show the list of places showList(); } if (item.getTitle().toString().equalsIgnoreCase(getString(R.string.filter))) { final FilterDialogFragment dialogFragment = new FilterDialogFragment(); final FilterContract.Presenter filterPresenter = new FilterPresenter(); dialogFragment.setPresenter(filterPresenter); dialogFragment.show(getActivity().getFragmentManager(), "dialog_fragment"); } if (item.getTitle().toString().equalsIgnoreCase("Route")) { mPresenter.getRoute(); } return false; } }); }