List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:com.github.pockethub.android.ui.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { int itemId = menuItem.getItemId(); if (itemId == R.id.navigation_home) { switchFragment(new HomePagerFragment(), org); getSupportActionBar().setTitle(getString(R.string.app_name)); return true; } else if (itemId == R.id.navigation_gists) { switchFragment(new GistsPagerFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_issue_dashboard) { switchFragment(new IssueDashboardPagerFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_bookmarks) { switchFragment(new FilterListFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_log_out) { AccountManager accountManager = getAccountManager(); Account[] allGitHubAccounts = accountManager.getAccountsByType(getString(R.string.account_type)); for (Account account : allGitHubAccounts) { accountManager.removeAccount(account, null, null); }/*from w w w .j a v a 2 s . co m*/ Intent in = new Intent(this, LoginActivity.class); in.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(in); finish(); return false; } else if (menuItemOrganizationMap.containsKey(menuItem)) { switchFragment(new HomePagerFragment(), menuItemOrganizationMap.get(menuItem)); navigationView.getMenu().findItem(R.id.navigation_home).setChecked(true); return false; } else { throw new IllegalStateException("MenuItem " + menuItem + " not known"); } }
From source file:locationkitapp.locationkit.locationkitapp.MapsActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.v(LOG_TAG, String.format("selected menu item %s", item.getTitle())); if (item.hasSubMenu()) { return true; }//ww w . j ava 2 s . c om if (item.getItemId() == R.id.action_getplace) { getPlace(); return true; } if (item.getItemId() == R.id.action_clear) { clearVisits(); return true; } if (item.getItemId() == R.id.action_email) { emailVisitHistory(); return true; } if (item.getItemId() == R.id.action_enable_disable_notifications) { flipNotifications(item); return true; } if (item.getItemId() == R.id.action_enable_disable_tracking) { flipTracking(item); return true; } if (item.getItemId() == R.id.action_show_info) { String url = "https://locationkit.io/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); return true; } return super.onOptionsItemSelected(item); }
From source file:com.brq.wallet.activity.modern.ModernMain.java
private void addEnglishSetting(MenuItem settingsItem) { String displayed = getResources().getString(R.string.settings); String settingsEn = Utils.loadEnglish(R.string.settings); if (!settingsEn.equals(displayed)) { settingsItem.setTitle(settingsItem.getTitle() + " (" + settingsEn + ")"); }/*from www . j a v a 2s. c om*/ }
From source file:com.horizonx.simplesaving.ScreenSlideActivity.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: if (item.getTitle() == getString(R.string.action_next)) { // Advance to the next step in the wizard. If there is no next step, setCurrentItem // will do nothing. mPager.setCurrentItem(mPager.getCurrentItem() + 1); return true; } else {/*from w ww .j a v a 2s .c om*/ Intent intent = new Intent(this, Settings.class); startActivity(intent); finish(); } } return super.onOptionsItemSelected(item); }
From source file:edu.berkeley.boinc.BOINCActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (Logging.DEBUG) Log.d(Logging.TAG, "BOINCActivity onOptionsItemSelected()"); // toggle drawer if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w. j a v a2 s . c o m 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); } }
From source file:com.irateam.vkplayer.activities.ListActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { drawerLayout.closeDrawers();//from www.j a va2 s. c o m if (menuItem.getGroupId() == R.id.audio_group) { if (searchView != null) { searchView.post(() -> MenuItemCompat.collapseActionView(toolbarMenu.findItem(R.id.action_search))); } getSupportActionBar().setTitle(menuItem.getTitle()); refreshLayout.setRefreshing(true); } if (menuItem.getItemId() == R.id.cached_audio && cacheUpdateReceiver == null) { cacheUpdateReceiver = new DownloadFinishedReceiver() { @Override public void onDownloadFinished(Audio audio) { audioAdapter.getList().add(0, audio); audioAdapter.notifyDataSetChanged(); } }; registerReceiver(cacheUpdateReceiver, new IntentFilter(DownloadService.DOWNLOAD_FINISHED)); } else if (cacheUpdateReceiver != null) { unregisterReceiver(cacheUpdateReceiver); cacheUpdateReceiver = null; } switch (menuItem.getItemId()) { case R.id.current_playlist: audioService.getCurrentAudio(); return true; case R.id.my_audio: audioService.getMyAudio(); return true; case R.id.recommended_audio: audioService.getRecommendationAudio(); return true; case R.id.popular_audio: audioService.getPopularAudio(); return true; case R.id.cached_audio: audioService.getCachedAudio(); return true; case R.id.settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.exit: VkLogout(); return true; } return false; }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomTabLayout.java
private void populateFromMenuResource(@NonNull MenuBuilder menuBuilder) { removeAllTabs();/*from w ww .ja v a2s. c om*/ int size = menuBuilder.size(); checkBottomItemGuidelines(size); for (int i = 0; i < size; i++) { MenuItem item = menuBuilder.getItem(i); BottomNavigationItem bottomNavigationItem = BottomNavigationItemBuilder.create(item.getIcon(), String.valueOf(item.getTitle()), getParentBackgroundColor(i)); bottomNavigationItem.setPosition(i); addBottomNavigationItem(bottomNavigationItem); } updateBottomNavViews(); }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE, getString(R.string.order_call_taxi_page_title)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//ww w .ja va 2s . com if (isShowOneKey) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.meetingninja.csse.notes.NotesFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.NOTES.getPosition()) { switch (item.getOrder()) { case 1: // Add Content Toast.makeText(getActivity(), String.format("%s", item.getTitle()), Toast.LENGTH_SHORT).show(); handled = true;/* ww w . j a v a2s . c om*/ break; case 2: // Delete delete(noteAdpt.getItem(position)); handled = true; break; case 3: Intent versionControl = new Intent(getActivity(), VersionControlActivity.class); startActivity(versionControl); handled = true; break; case 4: Note n = noteAdpt.getItem(position); if (mergeNote == null) { Log.d("MERGE", "merge_a: " + n.getID()); mergeNote = n; Toast.makeText(getActivity(), String.format("Select second note to merge."), Toast.LENGTH_LONG) .show(); } else if (mergeNote.getID().equalsIgnoreCase(n.getID())) { Log.d("MERGE", "merge_b: " + n.getID() + " : " + mergeNote.getID()); mergeNote = null; Toast.makeText(getActivity(), String.format("Error: Same note selected twice. Please reselect notes to merge."), Toast.LENGTH_LONG).show(); } else { Log.d("MERGE", "merge_c: " + n.getID() + " : " + mergeNote.getID()); Toast.makeText(getActivity(), String.format("Merging " + n.getTitle() + " into " + mergeNote.getTitle()), Toast.LENGTH_LONG).show(); mergeNote.setContent(mergeNote.getContent() + "\n" + n.getContent()); delete(n); updateNote(mergeNote); mergeNote = null; populateList(); } break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:net.kourlas.voipms_sms.activities.ConversationsActivity.java
/** * Called when an action mode item is clicked. * * @param mode The action mode containing the item that is clicked. * @param item The item that is clicked. * @return Returns true if the method handles the item clicked. */// www . j a v a2 s . co m @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.mark_read_unread_button: for (int i = 0; i < adapter.getItemCount(); i++) { if (adapter.isItemChecked(i)) { Message[] smses = adapter.getItem(i).getMessages(); for (Message message : smses) { message.setUnread(item.getTitle() .equals(getResources().getString(R.string.conversations_action_mark_unread))); database.insertMessage(message); } } } adapter.refresh(); mode.finish(); return true; case R.id.delete_button: List<Long> databaseIds = new ArrayList<>(); for (int i = 0; i < adapter.getItemCount(); i++) { if (adapter.isItemChecked(i)) { for (Message message : adapter.getItem(i).getMessages()) { if (message.getDatabaseId() != null) { databaseIds.add(message.getDatabaseId()); } } } } Long[] databaseIdsArray = new Long[databaseIds.size()]; databaseIds.toArray(databaseIdsArray); deleteMessages(databaseIdsArray); mode.finish(); return true; default: return false; } }