Example usage for android.view MenuItem getTitle

List of usage examples for android.view MenuItem getTitle

Introduction

In this page you can find the example usage for android.view MenuItem getTitle.

Prototype

public CharSequence getTitle();

Source Link

Document

Retrieve the current title of the item.

Usage

From source file:com.antonioleiva.materializeyourapp.MainActivity.java

private void setupDrawerLayout() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//  ww  w.  j av  a2  s. co m
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Snackbar.make(content, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show();
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            return true;
        }
    });
}

From source file:com.github.googlecodelabs.icon_shop.MainActivity.java

private void onProfessionSelected(MenuItem item) {
    final String profession = item.getTitle().toString();
    AsyncTask<Void, Void, Void> save = new AsyncTask<Void, Void, Void>() {
        @Override//from  w  w  w .j  a v a  2s  . co  m
        protected Void doInBackground(Void... voids) {
            App.setProfession(profession);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mSelectProfessionButton.setVisibility(View.GONE);
                }
            });
            return null;
        }
    }.execute();
}

From source file:net.granoeste.scaffold.util.TrackerToLog.java

@Override
public void trackOperation(final Activity activity, final MenuItem item) {
    if (activity == null) {
        return;/*from ww  w. j  a  v  a2  s  .  c o  m*/
    }
    if (item.getTitle() == null) {
        return;
    }
    track(activity, makeLogTag(((Object) activity).getClass()), item.getTitle().toString());
}

From source file:com.cranberrygame.phonegap.plugin.OptionsMenu.java

@Override
public Object onMessage(String id, Object data) {
    //https://github.com/dpogue/cordova-plugin-cambie/blob/master/src/android/Cambie.java
    //http://stackoverflow.com/questions/22403984/get-oncreateoptionsmenu-in-cordova-plugin
    //https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L140
    if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) {
        Menu menu = (Menu) data;

        if (this.menus != null) {
            menu.clear();/*from   w  w  w  .j  av a  2 s .  c o  m*/

            String[] _menus = this.menus.split(",");
            for (int i = 0; i < _menus.length; i++) {
                menu.add(0, i, 0, _menus[i]);
            }
        }
    } else if (id.equals("onOptionsItemSelected")) {
        MenuItem item = (MenuItem) data;

        webView.loadUrl(String.format("javascript:cordova.fireDocumentEvent('onMenuSelected', {'menu': '%s'});",
                item.getTitle()));
    }

    return null;
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_OrderFilter.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FINISH, Menu.NONE, getString(R.string.btn_finish));
    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  v  a 2 s.c om*/
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.deviceconnect.android.deviceplugin.irkit.settings.fragment.IRKitRegisterIRFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    final MenuItem menuItem = menu.add(getString(R.string.menu_close));
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override/*from   w w  w .  ja va 2 s.com*/
        public boolean onMenuItemClick(final MenuItem item) {
            if (item.getTitle().equals(menuItem.getTitle())) {
                getActivity().finish();
            }
            return true;
        }
    });
}

From source file:com.dj.hacktor.nshiddenlayout.MainActivity.java

private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override// w  w w .  j a v a2s .co  m
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            mDrawerLayout.closeDrawers();
            menuItem.setChecked(true);
            getSupportActionBar().setTitle(menuItem.getTitle());
            return true;
        }
    });
}

From source file:csci4176.toptentoday.MainActivity.java

public void onNavItemSelected(MenuItem menuItem) {
    switch (menuItem.getGroupId()) {
    case R.id.pref_filter_group:
        String stringToStore = menuItem.getTitle().toString().toLowerCase();
        SharedPreferences prefs = this.getSharedPreferences("prefs", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = prefs.edit();
        Set<String> filterSet = prefs.getStringSet("filter-list",
                new HashSet<String>(Arrays.asList("all-sections")));
        filterSet.add(stringToStore);/*from w  w  w.ja  va 2s .  com*/
        if (menuItem.getItemId() == R.id.pref_filter_all) {
            filterSet = new HashSet<String>(Arrays.asList("all-sections"));
        }
        edit.putStringSet("filter-list", filterSet);
        edit.commit();
        adapter.getArticles().refresh();
        return;
    default:
    }
    switch (menuItem.getItemId()) {
    case R.id.nav_licenses:
        Intent intent = new Intent(this, Licenses.class);
        startActivity(intent);
        break;
    }
    mDrawer.closeDrawers();
}

From source file:net.kjmaster.cookiemom.global.CookieActionActivity.java

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getTitle().equals(getString(R.string.cancel))) {
        setResult(RESULT_CANCELED);/*from   ww  w.  j  a  v a  2s.  co  m*/
        mode.finish();
        return true;
    }
    return true;
}

From source file:com.github.rubensousa.bottomsheetbuilder.adapter.BottomSheetMenuItem.java

public BottomSheetMenuItem(MenuItem item, @ColorInt int textColor, @DrawableRes int background,
        @ColorInt int tintColor) {
    mMenuItem = item;/*from   w w w.jav  a 2s  .  c  o  m*/
    mIcon = item.getIcon();
    mId = item.getItemId();
    mTitle = item.getTitle().toString();
    mTextColor = textColor;
    mBackground = background;
    mTintColor = tintColor;

    if (mTintColor != -1) {
        mIcon = DrawableCompat.wrap(mIcon);
        DrawableCompat.setTint(mIcon, mTintColor);
    }
}