Example usage for android.view MenuItem setTitle

List of usage examples for android.view MenuItem setTitle

Introduction

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

Prototype


public MenuItem setTitle(@StringRes int title);

Source Link

Document

Change the title associated with this item.

Usage

From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*from   w w  w.j  a v  a2 s. c  o m*/
    getMenuInflater().inflate(R.menu.missing_media_sortby, menu);
    MenuItem selectAll = menu.findItem(R.id.menu_select_all);
    if (selectAll != null) {
        selectAll.setVisible(missingMedia.size() != 0);
    }

    MenuItem sortBy = menu.findItem(R.id.menu_sort_by);
    if (sortBy != null) {
        sortBy.setVisible(missingMedia.size() != 0);
        sortBy.setTitle(isSortByCourse ? getString(R.string.menu_sort_by_filename)
                : getString(R.string.menu_sort_by_course));
    }
    return true;
}

From source file:org.mariotaku.twidere.fragment.UserListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    final ParcelableUserList userList = mUserList;
    MenuUtils.setMenuItemAvailability(menu, R.id.info, userList != null);
    menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION);
    if (userList != null) {
        final boolean isMyList = userList.user_key.equals(userList.account_key);
        final boolean isFollowing = userList.is_following;
        MenuUtils.setMenuItemAvailability(menu, R.id.edit, isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.follow, !isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.add, isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.delete, isMyList);
        final MenuItem followItem = menu.findItem(R.id.follow);
        if (isFollowing) {
            followItem.setIcon(R.drawable.ic_action_cancel);
            followItem.setTitle(R.string.unsubscribe);
        } else {//from w w  w. ja v  a  2s . c om
            followItem.setIcon(R.drawable.ic_action_add);
            followItem.setTitle(R.string.subscribe);
        }
        final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST);
        extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader());
        extensionsIntent.putExtra(EXTRA_USER_LIST, userList);
        MenuUtils.addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION);
    } else {
        MenuUtils.setMenuItemAvailability(menu, R.id.edit, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.follow, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.add, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.delete, false);
    }
}

From source file:de.tap.easy_xkcd.fragments.overview.OverviewListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_boomark:
        super.goToComic(bookmark - 1);
        break;/*from w w w .j  a v  a  2 s. c o m*/
    case R.id.action_unread:
        databaseManager.setComicsUnread();
        setupAdapter();
        break;
    case R.id.action_favorite:
        if (prefHelper.overviewFav()) {
            item.setIcon(R.drawable.ic_favorite_outline);
            item.setTitle(R.string.nv_favorites);
        } else {
            item.setIcon(R.drawable.ic_action_favorite);
            item.setTitle(R.string.action_overview);
        }
        prefHelper.setOverviewFav(!prefHelper.overviewFav());
        getActivity().invalidateOptionsMenu();
        setupAdapter();
        break;
    case R.id.action_hide_read:
        item.setChecked(!item.isChecked());
        prefHelper.setHideRead(item.isChecked());
        setupAdapter();
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.kjmaster.cookiemom.MainActivity.java

@OptionsItem({ R.id.menu_personal, R.id.menu_cookie_mom })
void onProfileSwitch(MenuItem item) {
    if (item.getTitle().toString().equals(getString(R.string.Personal))) {
        iSettings.dbName().put(iSettings.dbPersonalName().get());
        main.switchDb(iSettings.dbPersonalName().get());
        afterViews();//from  w w  w.j a v  a  2s  .  c o  m
        item.setTitle(R.string.cookie_mom);
    } else {
        iSettings.dbName().put(iSettings.dbCookieMomName().get());
        main.switchDb(iSettings.dbCookieMomName().get());
        afterViews();
        item.setTitle(R.string.Personal);
    }

}

From source file:paulscode.android.mupen64plusae.profile.ManageProfilesActivity.java

@Override
public void onPrepareMenuList(MenuListView listView) {

    // Popup a dialog with a context-sensitive list of options for the profile
    final Profile profile = (Profile) getListView().getItemAtPosition(mListViewPosition);

    if (profile.name.equals(getDefaultProfile())) {
        MenuItem defaultProfileItem = profile.isBuiltin
                ? listView.getMenu().findItem(R.id.menuItem_setUnsetDefaultBuiltinProfile)
                : listView.getMenu().findItem(R.id.menuItem_setUnsetDefaultCustomProfile);
        defaultProfileItem.setTitle(getString(R.string.listItem_unsetDefault));
    }/*from w  ww.  j  a  v a 2 s .  com*/
}

From source file:com.fa.mastodon.activity.AccountActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (!isSelf) {
        MenuItem follow = menu.findItem(R.id.action_follow);
        follow.setTitle(getFollowAction());
        follow.setVisible(followState != FollowState.REQUESTED);

        MenuItem block = menu.findItem(R.id.action_block);
        String title;/*from  www  . ja v  a  2s  .  c  om*/
        if (blocking) {
            title = getString(R.string.action_unblock);
        } else {
            title = getString(R.string.action_block);
        }
        block.setTitle(title);
        MenuItem mute = menu.findItem(R.id.action_mute);
        if (muting) {
            title = getString(R.string.action_unmute);
        } else {
            title = getString(R.string.action_mute);
        }
        mute.setTitle(title);
    } else {
        // It shouldn't be possible to block or follow yourself.
        menu.removeItem(R.id.action_follow);
        menu.removeItem(R.id.action_block);
        menu.removeItem(R.id.action_mute);
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item;

    item = menu.findItem(R.id.OrderByName);
    if (item != null) {
        if (mOrderByName)
            item.setTitle(getString(R.string.OrderByLevel));
        else//from   w  w w. j  av  a 2 s .c o  m
            item.setTitle(getString(R.string.OrderByName));
    }

    AugmentListView lv;

    item = menu.findItem(R.id.FilterByType);
    SubMenu submenu = item.getSubMenu();
    submenu.removeGroup(R.id.FilterByType);

    lv = (AugmentListView) findViewById(R.id.ListView);
    if (lv != null) {
        String types[] = lv.getAvailableWeaponTypes();

        if (types == null || types.length == 1) {
            item.setEnabled(false);
        } else {
            item.setEnabled(true);
            submenu.add(R.id.FilterByType, -1, Menu.NONE, getString(R.string.ResetFilterByType));
            for (int i = 0; i < types.length; i++) {
                submenu.add(R.id.FilterByType, i, Menu.NONE, types[i]);
            }
        }

    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.catnut.adapter.TweetAdapter.java

private void showPopupMenu(View view) {
    final Bean bean = (Bean) view.getTag();
    PopupMenu popup = new PopupMenu(mContext, view);
    Menu menu = popup.getMenu();/*from   w w  w.  j  av  a  2 s  .com*/
    popup.getMenuInflater().inflate(R.menu.tweet_overflow, menu);
    MenuItem item = menu.findItem(R.id.action_favorite);
    item.setTitle(bean.favorited ? R.string.cancle_favorite : R.string.favorite);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_favorite:
                mRequestQueue.add(new CatnutRequest(mContext,
                        bean.favorited ? FavoritesAPI.destroy(bean.id) : FavoritesAPI.create(bean.id),
                        new StatusProcessor.FavoriteTweetProcessor(), new Response.Listener<JSONObject>() {
                            @Override
                            public void onResponse(JSONObject response) {
                                Toast.makeText(mContext, bean.favorited ? R.string.cancle_favorite_success
                                        : R.string.favorite_success, Toast.LENGTH_SHORT).show();
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError error) {
                                WeiboAPIError weiboAPIError = WeiboAPIError.fromVolleyError(error);
                                Toast.makeText(mContext, weiboAPIError.error, Toast.LENGTH_LONG).show();
                            }
                        }));
                break;
            case R.id.action_like:
                Toast.makeText(mContext, "sina not provide this option...", Toast.LENGTH_SHORT).show();
                break;
            case android.R.id.copy:
                CatnutUtils.copy2ClipBoard(mContext, mContext.getString(R.string.tweet), bean.text,
                        mContext.getString(R.string.tweet_text_copied));
                break;
            default:
                break;
            }
            return false;
        }
    });
    popup.show();
}

From source file:com.darshancomputing.BatteryIndicator.CurrentInfoFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem snItem = menu.findItem(R.id.menu_show_notification);
    MenuItem closeItem = menu.findItem(R.id.menu_close);

    if (activity.sp_store.getBoolean(BatteryInfoService.KEY_SHOW_NOTIFICATION, true)) {
        snItem.setIcon(R.drawable.ic_menu_stop);
        snItem.setTitle(R.string.menu_hide_notification);
    } else {/* w w  w . j a  v a 2s  .  c  om*/
        snItem.setIcon(R.drawable.ic_menu_notifications);
        snItem.setTitle(R.string.menu_show_notification);
    }

    if (serviceCloseable)
        closeItem.setEnabled(true);
    else
        closeItem.setEnabled(false);
}

From source file:com.btmura.android.reddit.app.NavigationFragment.java

private void prepareAboutItem(Menu menu, boolean visible) {
    MenuItem item = menu.findItem(R.id.menu_subreddit);
    item.setVisible(visible);//from  w  ww  .  jav a 2 s  .  c  o  m
    if (visible) {
        item.setTitle(getString(R.string.menu_subreddit, getFirstCheckedSubreddit()));
    }
}