List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:cn.devit.app.ip_messenger.MainActivity.java
@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. Map<String, String> map = new HashMap<String, String>(1); map.put("menu_id", item.getTitle().toString()); int id = item.getItemId(); if (id == R.id.action_settings) { Intent i = new Intent(getApplicationContext(), SettingsActivity.class); startActivity(i);//from www . j ava 2 s. co m return true; } return super.onOptionsItemSelected(item); }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.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);/*from ww w. j a v a 2 s . co m*/ Utility driver = new Utility(getActivity()); if (isShowOneKey && driver.getAllDriverAccountInfo().isEmpty()) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.velli.passwordmanager.FragmentPasswords.java
@Override public void onNavigationItemSelection(MenuItem item) { super.onNavigationItemSelection(item); hideBottomSheet();//from w w w .ja va 2 s . co m mSelectedMenuItemId = item.getItemId(); String group = item.getTitle().toString(); if (mSelectedMenuItemId == -1 || (mSelectedMenuItemId == R.id.navigation_item_custom_group && group.isEmpty())) { getAllPasswords(NavigationDrawerConstants.NAVIGATION_ITEM_ALL); } switch (mSelectedMenuItemId) { case R.id.navigation_item_all: getAllPasswords(NavigationDrawerConstants.NAVIGATION_ITEM_ALL); break; case R.id.navigation_item_starred: getAllPasswords(NavigationDrawerConstants.NAVIGATION_ITEM_STARRED); break; case R.id.navigation_item_social: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_SOCIAL, null); break; case R.id.navigation_item_email: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_E_MAIL, null); break; case R.id.navigation_item_cloud: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_CLOUD_STORAGE, null); break; case R.id.navigation_item_e_commerce: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_WEB_SHOP, null); break; case R.id.navigation_item_web: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_WEB_LOGIN, null); break; case R.id.navigation_item_work: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_WORK, null); break; case R.id.navigation_item_bank: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_BANK, null); break; case R.id.navigation_item_app: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_APP, null); break; case R.id.navigation_item_credit_card: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_CREDIT_CARD, null); break; case R.id.navigation_item_gaming: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_GAMING, null); break; case R.id.navigation_item_messaging: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_MESSAGING, null); break; case R.id.navigation_item_wifi: getAllPasswordsByLabel(NavigationDrawerConstants.LABEL_WIFI, null); break; case R.id.navigation_item_custom_group: getAllPasswordsByGroup(group); break; case R.id.navigation_item_manage_groups: ApplicationBase.setActivityStatus(ApplicationBase.ACTIVITY_MANAGE_GROUPS, ApplicationBase.STATUS_STARTING_ACTIVITY, false); final Intent groups = new Intent(getActivity(), ActivityManageGroups.class); startActivity(groups); break; case R.id.navigation_item_settings: ApplicationBase.setActivityStatus(ApplicationBase.ACTIVITY_SETTINGS, ApplicationBase.STATUS_STARTING_ACTIVITY, false); final Intent settings = new Intent(getActivity(), ActivitySettings.class); getActivity().startActivityForResult(settings, ActivityMain.REQUEST_RECREATE); break; case R.id.navigation_item_log_out: if (!((ActivityMain) getActivity()).isSw600dpLayout()) { getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit(); } ((ActivityBase) getActivity()).logOut(); break; } }
From source file:com.jsw.MngProductDatabase.Home_Activity.java
public void setupDrawerContent() { mMngPharmacy = null;/*from ww w . ja va 2 s .c om*/ mManageProduct = null; mNav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override 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; default: item.setChecked(false); break; } mDrawer.closeDrawer(GravityCompat.START); setTitle(item.getTitle()); return true; } }); }
From source file:com.raja.knowme.FragmentContact.java
@Override public boolean onContextItemSelected(MenuItem item) { //if(isCallMenu) { //try {// w w w .j a va2 s. c o m // startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse("tel:"+item.getTitle().toString().trim()))); // } catch (ActivityNotFoundException e) { // Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show(); // } //} else { //if (mConnectivityManager.getActiveNetworkInfo() == null) // Toast.makeText(getActivity(), R.string.error_interenet_connection, Toast.LENGTH_SHORT).show(); //else { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { item.getTitle().toString().trim() }); startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.send_mail))); } //} return true; }
From source file:com.amaze.filemanager.ui.views.drawer.Drawer.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { actionViewStateManager.deselectCurrentActionView(); actionViewStateManager.selectActionView(item); isSomethingSelected = true;/*from w w w . j a v a 2 s. co m*/ String title = item.getTitle().toString(); MenuMetadata meta = dataUtils.getDrawerMetadata(item); switch (meta.type) { case MenuMetadata.ITEM_ENTRY: if (dataUtils.containsBooks(new String[] { title, meta.path }) != -1) { FileUtils.checkForPath(mainActivity, meta.path, mainActivity.isRootExplorer()); } if (dataUtils.getAccounts().size() > 0 && (meta.path.startsWith(CloudHandler.CLOUD_PREFIX_BOX) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_DROPBOX) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_ONE_DRIVE) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE))) { // we have cloud accounts, try see if token is expired or not CloudUtil.checkToken(meta.path, mainActivity); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && meta.path.contains(OTGUtil.PREFIX_OTG) && SingletonUsbOtg.getInstance().getUsbOtgRoot() == null) { MaterialDialog dialog = GeneralDialogCreation.showOtgSafExplanationDialog(mainActivity); dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener((v) -> { SingletonUsbOtg.getInstance().setHasRootBeenRequested(true); Intent safIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); mainActivity.startActivityForResult(safIntent, MainActivity.REQUEST_CODE_SAF); dialog.dismiss(); }); dialog.show(); } else { pendingPath = meta.path; closeIfNotLocked(); if (isLocked()) { onDrawerClosed(); } } break; case MenuMetadata.ITEM_INTENT: meta.onClickListener.onClick(); break; } return true; }
From source file:org.fundsofhope.androidapp.activities.MainActivity.java
public void selectDrawerItem(MenuItem menuItem) { Intent intent;/* w ww .j a v a 2s. c o m*/ switch (menuItem.getItemId()) { case R.id.nav_first_fragment: intent = new Intent(this, MainActivity.class); break; case R.id.nav_second_fragment: intent = new Intent(this, TransitionFirstActivity.class); break; case R.id.nav_third_fragment: intent = new Intent(this, ProjectsActivity.class); break; default: intent = new Intent(this, MainActivity.class); break; } startActivity(intent); menuItem.setChecked(true); setTitle(menuItem.getTitle()); mDrawer.closeDrawers(); }
From source file:com.offsec.nethunter.AppNavHomeActivity.java
private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from w w w .jav a 2 s . c o m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { // only change it if is no the same as the last one if (lastSelected != menuItem) { //remove last lastSelected.setChecked(false); // udpate for the next lastSelected = menuItem; } //set checked menuItem.setChecked(true); mDrawerLayout.closeDrawers(); mTitle = menuItem.getTitle(); titles.push(mTitle.toString()); FragmentManager fragmentManager = getSupportFragmentManager(); int itemId = menuItem.getItemId(); switch (itemId) { case R.id.nethunter_item: fragmentManager.beginTransaction() .replace(R.id.container, NetHunterFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; /* case R.id.kalilauncher_item: fragmentManager .beginTransaction() .replace(R.id.container, KaliLauncherFragment.newInstance(itemId)) .addToBackStack(null) .commit(); break; */ case R.id.kaliservices_item: fragmentManager.beginTransaction() .replace(R.id.container, KaliServicesFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.custom_commands_item: fragmentManager.beginTransaction() .replace(R.id.container, CustomCommandsFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.hid_item: fragmentManager.beginTransaction().replace(R.id.container, HidFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.duckhunter_item: fragmentManager.beginTransaction() .replace(R.id.container, DuckHunterFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.badusb_item: fragmentManager.beginTransaction().replace(R.id.container, BadusbFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.mana_item: fragmentManager.beginTransaction().replace(R.id.container, ManaFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.macchanger_item: fragmentManager.beginTransaction() .replace(R.id.container, MacchangerFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.createchroot_item: fragmentManager.beginTransaction() .replace(R.id.container, ChrootManagerFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.mpc_item: fragmentManager.beginTransaction().replace(R.id.container, MPCFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.mitmf_item: fragmentManager.beginTransaction().replace(R.id.container, MITMfFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.vnc_item: fragmentManager.beginTransaction().replace(R.id.container, VNCFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.searchsploit_item: fragmentManager.beginTransaction() .replace(R.id.container, SearchSploitFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.nmap_item: fragmentManager.beginTransaction().replace(R.id.container, NmapFragment.newInstance(itemId)) .addToBackStack(null).commit(); break; case R.id.pineapple_item: fragmentManager.beginTransaction() .replace(R.id.container, PineappleFragment.newInstance(itemId)).addToBackStack(null) .commit(); break; case R.id.checkforupdate_item: checkUpdate(); break; } restoreActionBar(); return true; } }); }
From source file:com.jwetherell.quick_response_code.EncoderActivity.java
@SuppressLint("NewApi") public OnClickListener onclickPopUpMenu(MenuItem item) { //Creating the instance of PopupMenu PopupMenu popup = new PopupMenu(EncoderActivity.this, item.getActionView()); //Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.menu_contextual_wps, popup.getMenu()); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Toast.makeText(EncoderActivity.this, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show(); return true; }/*from w w w . j av a 2s. c o m*/ }); popup.show(); //showing popup menu return null; }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * Actions of the selected context menu entry. *//*from www .j a v a 2 s . c o m*/ public boolean onContextItemSelected(MenuItem item) { // Remove default entry if (item.getTitle().equals(getString(R.string.cmenu_remstd))) { Preferences.setDefaultFile(getApplicationContext(), ""); // Start navigation } else if (item.getTitle().equals(getString(R.string.cmenu_nav))) { showNavigation(); // Display share options } else if (item.getTitle().equals(getString(R.string.cmenu_share))) { showShareOptions(); // Show Building information } else if (item.getTitle().equals(getString(R.string.cmenu_info))) { showBuildingInformation(); // Set filter } else if (item.getTitle().equals(getString(R.string.cmenu_filter))) { showFilterOptions(); // Display the legende } else if (item.getTitle().equals(getString(R.string.cmenu_legende))) { showSymbolLegend(); } return super.onContextItemSelected(item); }