List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:paddle.blockm.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SugarContext.init(this); setContentView(R.layout.activity_main); ButterKnife.bind(this); // Adding Toolbar to Main screen setSupportActionBar(toolbar);//from w w w.j a va2 s . c om // Setting ViewPager for each Tabs setupViewPager(viewPager); // Set Tabs inside Toolbar tabs.setupWithViewPager(viewPager); // Adding menu icon to Toolbar ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); supportActionBar.setDisplayHomeAsUpEnabled(true); } // Set behavior of Navigation drawer navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { // Set item in checked state menuItem.setChecked(true); mDrawerLayout.closeDrawers(); if (menuItem.getTitle().equals("Blacklist")) { Intent intent = new Intent(MainActivity.this, BlacklistActivity.class); startActivity(intent); } return true; } }); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); }
From source file:com.jwork.dhammapada.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { log.v(this, "onOptionsItemSelected(" + item.getTitle() + ")"); String appName = getString(R.string.app_name); String appPackage = getPackageName(); switch (item.getItemId()) { case R.id.action_rate: Uri uri = Uri.parse("market://details?id=" + appPackage); Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri); try {//from w w w . ja v a 2 s .com startActivity(myAppLinkToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(this, "Failed to find Market application", Toast.LENGTH_LONG).show(); } break; case R.id.action_donate: openDonate(); break; case R.id.action_share: Intent intentText = new Intent(Intent.ACTION_SEND); intentText.setType("text/plain"); intentText.putExtra(Intent.EXTRA_SUBJECT, appName); intentText.putExtra(Intent.EXTRA_TEXT, "Check out " + appName + " on Google Play! https://play.google.com/store/apps/details?id=" + appPackage); try { startActivity(Intent.createChooser(intentText, getString(R.string.share_this_app_intent))); } catch (ActivityNotFoundException e) { Toast.makeText(this, "Failed to share this application", Toast.LENGTH_LONG).show(); } break; case R.id.action_about: aboutWindow.showAtLocation(this.findViewById(R.id.mainLayout), Gravity.CENTER, 0, 0); mainLayout.getForeground().setAlpha(200); break; case R.id.action_feedback: Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String subject = "[" + Constant.APP_NAME + "] Feedback"; sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jwork.dhammapada.os@gmail.com" }); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.putExtra(Intent.EXTRA_TEXT, "\n-------------------------------\n" + CrashHandler.getPhoneInfo(this)); sendIntent.setType("message/rfc822"); startActivity(Intent.createChooser(sendIntent, "Email:")); break; } // TODO Auto-generated method stub return super.onContextItemSelected(item); }
From source file:com.chale22.ico01.fragments.FragmentExtras.java
public void onMenuItemClick(Card card, MenuItem item) { Toast.makeText(getActivity(), card.getTitle() + ": " + item.getTitle(), Toast.LENGTH_SHORT).show(); }
From source file:com.vrem.wifianalyzer.navigation.items.FragmentItem.java
@Override public void activate(@NonNull MainActivity mainActivity, @NonNull MenuItem menuItem, @NonNull NavigationMenu navigationMenu) { NavigationMenuView navigationMenuView = mainActivity.getNavigationMenuView(); navigationMenuView.setCurrentNavigationMenu(navigationMenu); startFragment(mainActivity);/* w ww . j a v a 2 s .c om*/ mainActivity.setTitle(menuItem.getTitle()); mainActivity.updateActionBar(); }
From source file:com.android.screenspeak.contextmenu.ListMenuManager.java
private CharSequence[] getItemsFromMenu(Menu menu) { int size = menu.size(); List<CharSequence> items = new ArrayList<>(); for (int i = 0; i < size; i++) { MenuItem item = menu.getItem(i); if (item != null && item.isEnabled() && item.isVisible()) { items.add(item.getTitle()); }/*from w w w . j a va 2s . c om*/ } return items.toArray(new CharSequence[items.size()]); }
From source file:com.example.angelina.travelapp.places.PlacesActivity.java
/** * Set up toolbar//from w w w . jav a 2 s. c o m */ private void setUpToolbar() { final Toolbar toolbar = (Toolbar) findViewById(R.id.placeList_toolbar); setSupportActionBar(toolbar); assert toolbar != null; toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { if (item.getTitle().toString().equalsIgnoreCase(getString(R.string.map_view))) { // Hide the list, show the map showMap(); } if (item.getTitle().toString().equalsIgnoreCase(getString(R.string.filter))) { final FilterDialogFragment dialogFragment = new FilterDialogFragment(); final FilterPresenter filterPresenter = new FilterPresenter(); dialogFragment.setPresenter(filterPresenter); dialogFragment.show(getFragmentManager(), "dialog_fragment"); } return false; } }); }
From source file:am.project.x.business.main.MainActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { ViewUtils.setLayoutFullscreen(getWindow().getDecorView(), false); final Toolbar toolbar = findViewById(R.id.main_toolbar); mVDrawer = findViewById(R.id.main_drawer); mVContent = findViewById(R.id.main_lyt_content); final NavigationView navigation = findViewById(R.id.main_navigation); setSupportActionBar(toolbar);//ww w .j a va 2 s . c o m final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mVDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); toggle.setToolbarNavigationClickListener(this); mVDrawer.addDrawerListener(toggle); toggle.syncState(); navigation.setNavigationItemSelectedListener(this); final String tag; final boolean debug = BuildConfig.DEBUG; if (savedInstanceState == null) { tag = TAG_WIDGETS; final MenuItem item = navigation.getMenu().findItem(R.id.main_nav_widgets); item.setChecked(true); setTitle(item.getTitle()); if (debug) DevelopingActivity.start(this); } else { tag = savedInstanceState.getString(EXTRA_FRAGMENT, TAG_WIDGETS); MenuItem item; switch (tag) { default: case TAG_WIDGETS: item = navigation.getMenu().findItem(R.id.main_nav_widgets); break; case TAG_DRAWABLES: item = navigation.getMenu().findItem(R.id.main_nav_drawables); break; case TAG_OTHERS: item = navigation.getMenu().findItem(R.id.main_nav_others); break; case TAG_DEVELOP: item = navigation.getMenu().findItem(R.id.main_nav_develop); break; } item.setChecked(true); setTitle(item.getTitle()); } final MenuItem develop = navigation.getMenu().findItem(R.id.main_nav_develop); develop.setVisible(debug); setFragment(tag); }
From source file:de.spiritcroc.ownlog.ui.view.EditTagsView.java
private void showAddTagMenu() { // Ensure we have a tags provider if (mTagsProvider == null) { Log.e(TAG, "Cannot load tags: no tags provider"); return;// w w w. j a va 2 s . c o m } // Use context from activity instead of getContext() to separate popup from // this view's theme (padding etc.) PopupMenu popupMenu = new PopupMenu(mTagsProvider.getActivity(), mAddTagButton); Menu menu = popupMenu.getMenu(); final List<TagItem> availableTags = mTagsProvider.getAvailableTags(); final List<TagItem> setTags = mTagsProvider.getSetTags(); final HashMap<String, TagItem> tagMap = new HashMap<>(); for (TagItem tag : availableTags) { if (mAvailableTagsFilter.shouldShowTag(tag)) { menu.add(tag.name); tagMap.put(tag.name, tag); } } menu.add(R.string.edit_log_tags_add_new); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { String name = menuItem.getTitle().toString(); if (tagMap.containsKey(name)) { setTags.add(tagMap.get(name)); mTagsProvider.onSetTagsChanged(); updateContent(); } else { new TagItemEditFragment().show(mTagsProvider.getActivity().getFragmentManager(), "TagItemEditFragment"); } return false; } }); popupMenu.show(); }
From source file:nyc.c4q.jordansmith.finefree.ActivityMain.java
public void selectDrawerItem(final MenuItem menuItem) { switch (menuItem.getTitle().toString()) { case "Home": startDefaultHomeFragment();// w w w.jav a2 s.co m break; case "Settings": getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, new FragmentSettings()) .commit(); break; case "Add New Car": getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, new FragmentNewCar()) .commit(); break; } // Submenu of cars String plate; for (int i = 0; i < cars.size(); i++) { if (cars.get(i).getName().equals(menuItem.getTitle())) { plate = cars.get(i).getLicensePlate(); Bundle bundle = new Bundle(); bundle.putSerializable(PLATE_KEY, cars.get(i)); FragmentHome fragmentHome = new FragmentHome(); fragmentHome.setArguments(bundle); getSupportFragmentManager().beginTransaction() .setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit) .replace(R.id.fragment_holder, fragmentHome).commit(); } } menuItem.setChecked(true); setTitle(menuItem.getTitle()); drawerLayout.closeDrawers(); }
From source file:roommateapp.info.droid.ActivityIntroduction.java
/** * /* w w w . j a v a 2s . c om*/ */ @Override public boolean onOptionsItemSelected(MenuItem item) { String selItem = (String) item.getTitle(); View v = getWindow().getDecorView().findViewById(android.R.id.content); if (selItem.equals(getString(R.string.menu_addfile))) { onClickGoToAddFile(v); } else if (selItem.equals(getString(R.string.title_settings))) { onClickGoToSettings(v); } else if (selItem.equals(getString(R.string.title_about))) { onClickGoToAbout(v); } return true; }