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:com.app.uafeed.activity.HomeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        // return true;
    }/*from ww  w .j  a v a2  s .  com*/

    switch (item.getItemId()) {
    case R.id.menu_hide_read_main:
        if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, true);
            item.setTitle(R.string.context_menu_hide_read).setIcon(R.drawable.hide_reads);
        } else {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, false);
            item.setTitle(R.string.context_menu_show_read).setIcon(R.drawable.view_reads);
        }
        return true;
    /*case R.id.menu_edit:
        startActivity(new Intent(this, EditFeedsListActivity.class));
        return true;
        */
    case R.id.menu_refresh_main:
        if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) {
            MainApplication.getContext()
                    .startService(new Intent(MainApplication.getContext(), FetcherService.class)
                            .setAction(FetcherService.ACTION_REFRESH_FEEDS));
        }
        return true;
    case R.id.menu_settings_main:
        //startActivity(new Intent(this, GeneralPrefsActivity.class));
        startActivity(new Intent(this, ProjectsActivity.class));
        return true;

    case R.id.menu_about_main:
        startActivity(new Intent(this, AboutActivity.class));

        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:fr.kwiatkowski.apktrack.MainActivity.java

private boolean _toggle_show_system_apps(MenuItem item) {
    // The user's choice is stored as a preference.
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean show_system = pref.getBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM, false);
    List<InstalledApp> system_apps = InstalledApp.find(InstalledApp.class, "_isignored = 0 AND _systemapp = 1");
    if (show_system) {
        Log.v(TAG, "Hiding system apps.");
        _app_display.remove_apps(system_apps);
        item.setTitle(R.string.show_system_apps);
    } else {/* w  w w.  j av  a  2 s .  c  om*/
        Log.v(TAG, "Showing system apps.");
        _app_display.add_apps(system_apps);
        item.setTitle(R.string.hide_system_apps);
    }

    pref.edit().putBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM, !show_system).apply(); // Toggle the preference.
    return true;
}

From source file:com.android.mail.ui.ActionBarController.java

public void setConversationModeOptions(Menu menu) {
    if (mCurrentConversation == null) {
        return;//from w ww . j a  v  a  2  s. co  m
    }
    final boolean showMarkImportant = !mCurrentConversation.isImportant();
    Utils.setMenuItemVisibility(menu, R.id.mark_important,
            showMarkImportant && mAccount.supportsCapability(UIProvider.AccountCapabilities.MARK_IMPORTANT));
    Utils.setMenuItemVisibility(menu, R.id.mark_not_important,
            !showMarkImportant && mAccount.supportsCapability(UIProvider.AccountCapabilities.MARK_IMPORTANT));
    final boolean isOutbox = mFolder.isType(FolderType.OUTBOX);
    final boolean showDiscardOutbox = mFolder != null && isOutbox
            && mCurrentConversation.sendingState == UIProvider.ConversationSendingState.SEND_ERROR;
    Utils.setMenuItemVisibility(menu, R.id.discard_outbox, showDiscardOutbox);
    final boolean showDelete = !isOutbox && mFolder != null
            && mFolder.supportsCapability(UIProvider.FolderCapabilities.DELETE);
    Utils.setMenuItemVisibility(menu, R.id.delete, showDelete);
    // We only want to show the discard drafts menu item if we are not showing the delete menu
    // item, and the current folder is a draft folder and the account supports discarding
    // drafts for a conversation
    final boolean showDiscardDrafts = !showDelete && mFolder != null && mFolder.isDraft()
            && mAccount.supportsCapability(AccountCapabilities.DISCARD_CONVERSATION_DRAFTS);
    Utils.setMenuItemVisibility(menu, R.id.discard_drafts, showDiscardDrafts);
    final boolean archiveVisible = mAccount.supportsCapability(AccountCapabilities.ARCHIVE) && mFolder != null
            && mFolder.supportsCapability(FolderCapabilities.ARCHIVE) && !mFolder.isTrash();
    Utils.setMenuItemVisibility(menu, R.id.archive, archiveVisible);
    Utils.setMenuItemVisibility(menu, R.id.remove_folder,
            !archiveVisible && mFolder != null
                    && mFolder.supportsCapability(FolderCapabilities.CAN_ACCEPT_MOVED_MESSAGES)
                    && !mFolder.isProviderFolder() && mAccount.supportsCapability(AccountCapabilities.ARCHIVE));
    Utils.setMenuItemVisibility(menu, R.id.move_to,
            mFolder != null && mFolder.supportsCapability(FolderCapabilities.ALLOWS_REMOVE_CONVERSATION));
    Utils.setMenuItemVisibility(menu, R.id.move_to_inbox,
            mFolder != null && mFolder.supportsCapability(FolderCapabilities.ALLOWS_MOVE_TO_INBOX));
    Utils.setMenuItemVisibility(menu, R.id.change_folders,
            mAccount.supportsCapability(UIProvider.AccountCapabilities.MULTIPLE_FOLDERS_PER_CONV));

    final MenuItem removeFolder = menu.findItem(R.id.remove_folder);
    if (mFolder != null && removeFolder != null) {
        removeFolder
                .setTitle(mActivity.getApplicationContext().getString(R.string.remove_folder, mFolder.name));
    }
    Utils.setMenuItemVisibility(menu, R.id.report_spam,
            mAccount.supportsCapability(AccountCapabilities.REPORT_SPAM) && mFolder != null
                    && mFolder.supportsCapability(FolderCapabilities.REPORT_SPAM)
                    && !mCurrentConversation.spam);
    Utils.setMenuItemVisibility(menu, R.id.mark_not_spam,
            mAccount.supportsCapability(AccountCapabilities.REPORT_SPAM) && mFolder != null
                    && mFolder.supportsCapability(FolderCapabilities.MARK_NOT_SPAM)
                    && mCurrentConversation.spam);
    Utils.setMenuItemVisibility(menu, R.id.report_phishing,
            mAccount.supportsCapability(AccountCapabilities.REPORT_PHISHING) && mFolder != null
                    && mFolder.supportsCapability(FolderCapabilities.REPORT_PHISHING)
                    && !mCurrentConversation.phishing);
    Utils.setMenuItemVisibility(menu, R.id.mute,
            mAccount.supportsCapability(AccountCapabilities.MUTE) && mFolder != null
                    && mFolder.supportsCapability(FolderCapabilities.DESTRUCTIVE_MUTE)
                    && !mCurrentConversation.muted);
}

From source file:net.news.inrss.fragment.EntryFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.entry, menu);

    if (mFavorite) {
        MenuItem item = menu.findItem(R.id.menu_star);
        item.setTitle(R.string.menu_unstar).setIcon(R.drawable.ic_star);
    }//from w  ww  . j a  va 2  s . c om
    mShowFullContentItem = menu.findItem(R.id.menu_switch_full_original);
    mShowFullContentItem.setChecked(mPreferFullText);

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java

private void setCurrentMode(MediaType mode) {
    currentMediaMode = mode;/*from  w w  w  . j  a v  a2  s. c om*/
    if (currentMediaMode == MediaType.IMAGE) {
        if (mMenu != null) {
            MenuItem item = mMenu.findItem(R.id.menuCamera);
            item.setIcon(R.drawable.selector_camera_button);
            item.setTitle(getString(R.string.image));
        }

        getActionBar().setTitle(getString(R.string.image));
    } else {
        if (mMenu != null) {
            MenuItem item = mMenu.findItem(R.id.menuCamera);
            item.setIcon(R.drawable.selector_video_button);
            item.setTitle(getString(R.string.video));
        }
        getActionBar().setTitle(getString(R.string.video));
    }
}

From source file:de.jadehs.jadehsnavigator.fragment.MensaplanFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    //return super.onOptionsItemSelected(item);
    switch (item.getItemId()) {
    case R.id.refresh_mensaplan:

        updateMensaplan(true);/*from www. j a  v  a  2  s.c  o m*/
        break;
    case R.id.changeWeek_mensaplan:
        if (!nextWeek) {

            nextWeek = true;
            this.week = week + 1;
            updateMensaplan(false);

            item.setTitle("Zurck zur aktuellen Woche");

        } else {
            nextWeek = false;
            item.setTitle("Nchste Woche");
            this.week = 0;
            updateMensaplan(false);

        }
        Toast.makeText(getActivity().getApplicationContext(), "Woche gewechselt.", Toast.LENGTH_SHORT).show();
        break;
    case R.id.mensaplan_action_info:
        showDialog();

    default:
        return super.onOptionsItemSelected(item);
    }
    return super.onOptionsItemSelected(item);
}

From source file:de.tap.easy_xkcd.fragments.comics.ComicFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    //Update the favorites icon
    MenuItem fav = menu.findItem(R.id.action_favorite);
    if (databaseManager.checkFavorite(lastComicNumber)) {
        fav.setIcon(R.drawable.ic_action_favorite);
        fav.setTitle(R.string.action_favorite_remove);
    } else {//w  w  w  . j a  v  a2 s . com
        fav.setIcon(R.drawable.ic_favorite_outline);
        fav.setTitle(R.string.action_favorite);
    }
    //If the FAB is visible, hide the random comic menu item
    if (((MainActivity) getActivity()).getFab().getVisibility() == View.GONE) {
        menu.findItem(R.id.action_random).setVisible(true);
    } else {
        menu.findItem(R.id.action_random).setVisible(false);
    }
    menu.findItem(R.id.action_alt).setVisible(prefHelper.showAltTip());
    if (Arrays.binarySearch(getResources().getIntArray(R.array.interactive_comics), lastComicNumber) >= 0)
        menu.findItem(R.id.action_browser).setVisible(true);
}

From source file:io.plaidapp.ui.HomeActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem dribbbleLogin = menu.findItem(R.id.menu_dribbble_login);
    if (dribbbleLogin != null) {
        dribbbleLogin
                .setTitle(dribbblePrefs.isLoggedIn() ? R.string.dribbble_log_out : R.string.dribbble_login);
    }/*from   w  w  w.  j av a 2 s .c  om*/
    MenuItem designerNewsLogin = menu.findItem(R.id.menu_designer_news_login);
    if (designerNewsLogin != null) {
        designerNewsLogin.setTitle(
                designerNewsPrefs.isLoggedIn() ? R.string.designer_news_log_out : R.string.designer_news_login);
    }

    return true;
}

From source file:org.freespanish.diccionario.fragments.search.SearchFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_fav) {
        Definition definition = this.searchPresenter.notifyDefinitionToRetrieve("word = ?", this.currentWord,
                getActivity());/*from  w ww  .  j  a  v  a 2 s  .c  o m*/

        if (definition != null) {
            definition.isFavorite = !definition.isFavorite;
            item.setIcon(definition.isFavorite ? R.drawable.ic_favorite_white_24dp
                    : R.drawable.ic_favorite_border_white_24dp);
            item.setTitle(definition.isFavorite ? getString(R.string.add_fav_text)
                    : getString(R.string.remove_fav_text));
            this.searchPresenter.notifyDefinitionToStore(definition, getActivity());
        }

    }

    return super.onOptionsItemSelected(item);
}

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

@Override
public void onPrepareOptionsMenu(Menu menu) {
    final ParcelableUserList userList = mUserList;
    setMenuItemAvailability(menu, MENU_INFO, userList != null);
    menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION);
    if (userList != null) {
        final boolean isMyList = userList.user_id == userList.account_id;
        final boolean isFollowing = userList.is_following;
        setMenuItemAvailability(menu, MENU_EDIT, isMyList);
        setMenuItemAvailability(menu, MENU_FOLLOW, !isMyList);
        setMenuItemAvailability(menu, MENU_ADD, isMyList);
        setMenuItemAvailability(menu, MENU_DELETE, isMyList);
        final MenuItem followItem = menu.findItem(MENU_FOLLOW);
        if (isFollowing) {
            followItem.setIcon(R.drawable.ic_action_cancel);
            followItem.setTitle(R.string.unsubscribe);
        } else {/*from www.j a  v a2s  . c o  m*/
            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);
        addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION);
    } else {
        setMenuItemAvailability(menu, MENU_EDIT, false);
        setMenuItemAvailability(menu, MENU_FOLLOW, false);
        setMenuItemAvailability(menu, MENU_ADD, false);
        setMenuItemAvailability(menu, MENU_DELETE, false);
    }
}