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.fastaccess.ui.modules.repos.RepoPagerActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Repo repoModel = getPresenter().getRepo();
    if (repoModel != null && repoModel.isFork() && repoModel.getParent() != null) {
        MenuItem menuItem = menu.findItem(R.id.originalRepo);
        menuItem.setVisible(true);/* w w w . jav  a 2 s .  c om*/
        menuItem.setTitle(repoModel.getParent().getFullName());
    }
    //        menu.findItem(R.id.deleteRepo).setVisible(getPresenter().isRepoOwner());
    if (menu.findItem(R.id.deleteRepo) != null)
        menu.findItem(R.id.deleteRepo).setVisible(false);//removing delete permission.
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.bar.foldinglayout.sample.FoldingLayoutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.animate_fold:
        animateFold();//from  w ww .j  ava2s  .c om
        break;
    case R.id.toggle_orientation:
        mOrientation = (mOrientation == BaseFoldingLayout.Orientation.HORIZONTAL)
                ? BaseFoldingLayout.Orientation.VERTICAL
                : BaseFoldingLayout.Orientation.HORIZONTAL;
        item.setTitle((mOrientation == BaseFoldingLayout.Orientation.HORIZONTAL) ? R.string.vertical
                : R.string.horizontal);
        // mTranslation = 0;
        mFoldLayout.setOrientation(mOrientation);
        break;
    case R.id.camera_feed:
        if (IS_ISC) {
            mIsCameraFeed = !mIsCameraFeed;
            item.setTitle(mIsCameraFeed ? R.string.static_image : R.string.camera_feed);
            item.setChecked(mIsCameraFeed);
            if (mIsCameraFeed) {
                //   mFoldLayout.removeView(mImageView);
                //   mFoldLayout.addView(mTextureView,
                //      new ViewGroup.LayoutParams(mFoldLayout.getWidth(),
                //            mFoldLayout.getHeight()));
            } else {
                //mFoldLayout.removeView(mTextureView);
                //mFoldLayout.addView(mImageView, new ViewGroup.LayoutParams(
                //      mFoldLayout.getWidth(), mFoldLayout.getHeight()));
            }
            // mTranslation = 0;
        }
        break;
    case R.id.sepia:
        mIsSepiaOn = !mIsSepiaOn;
        item.setChecked(mIsSepiaOn);
        if (mIsSepiaOn && mFoldLayout.getFoldFactor() != 0) {
            setSepiaLayer(mFoldLayout.getChildAt(0), true);
        } else {
            setSepiaLayer(mFoldLayout.getChildAt(0), false);
        }
        break;
    default:
        break;

    }
    return super.onOptionsItemSelected(item);
}

From source file:com.jwetherell.quick_response_code.EncoderActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.btnshare:
        OnClickShare(null);/*from ww  w.  j  a v  a2s .  co  m*/
        return true;
    case android.R.id.home:
        onBackPressed();
        return true;
    case R.id.empty:
        Statistics.getInstance(EncoderActivity.this).click();
        View menuItemView = findViewById(R.id.empty);
        PopupMenu popupMenu = new PopupMenu(this, menuItemView);
        popupMenu.inflate(R.menu.menu_contextual_wps);
        for (int i = 0; i < popupMenu.getMenu().size(); i++) {
            MenuItem itemMenu = popupMenu.getMenu().getItem(i);
            SpannableString spanString = new SpannableString(
                    popupMenu.getMenu().getItem(i).getTitle().toString());
            spanString.setSpan(new ForegroundColorSpan(Color.BLACK), 0, spanString.length(), 0);
            itemMenu.setTitle(spanString);
        }
        popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                Statistics.getInstance(EncoderActivity.this).click();
                // TODO Auto-generated method stub
                switch (item.getItemId()) {
                case R.id.wps:
                    Statistics.getInstance(EncoderActivity.this).sendStatistics(TAGS.TAG_31);
                    Intent mIntent = new Intent(EncoderActivity.this, AVActivateWpsActivity.class);
                    mIntent.putExtra("is_5ghz", getIntent().getBooleanExtra("is_5ghz", false));
                    startActivity(mIntent);
                    break;

                default:
                    break;
                }

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

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.FavouriteStopsFragment.java

/**
 * {@inheritDoc}//from ww  w  . j  ava 2s  . co  m
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    // Get the menu inflater.
    final MenuInflater inflater = getActivity().getMenuInflater();
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final Cursor c = (Cursor) ca.getItem(info.position);
    final String selectedStopCode;

    // Get the stopCode.
    if (c != null) {
        selectedStopCode = String.valueOf(c.getString(0));
    } else {
        selectedStopCode = "";
    }

    // Set the header title of the context menu.
    menu.setHeaderTitle(getString(R.string.busstop, sd.getNameForStop(selectedStopCode), selectedStopCode));
    // Inflate the menu from XML.
    inflater.inflate(R.menu.favouritestops_context_menu, menu);

    // Set the title of the proximity alert item depending whether one is
    // set or not.
    MenuItem item = menu.findItem(R.id.favouritestops_context_menu_prox_alert);

    if (sd.isActiveProximityAlert(selectedStopCode)) {
        item.setTitle(R.string.favouritestops_menu_prox_rem);
    } else {
        item.setTitle(R.string.favouritestops_menu_prox_add);
    }

    // Set the title of the time alert item depending whether one is set or
    // not.
    item = menu.findItem(R.id.favouritestops_context_menu_time_alert);

    if (sd.isActiveTimeAlert(selectedStopCode)) {
        item.setTitle(R.string.favouritestops_menu_time_rem);
    } else {
        item.setTitle(R.string.favouritestops_menu_time_add);
    }

    // If the Google Play Services is not available, then don't show the
    // option to show the stop on the map.
    item = menu.findItem(R.id.favouritestops_context_menu_showonmap);

    if (!GenericUtils.isGoogleMapsAvailable(getActivity())) {
        item.setVisible(false);
    }
}

From source file:com.brq.wallet.activity.modern.ModernMain.java

private void addEnglishSetting(MenuItem settingsItem) {
    String displayed = getResources().getString(R.string.settings);
    String settingsEn = Utils.loadEnglish(R.string.settings);
    if (!settingsEn.equals(displayed)) {
        settingsItem.setTitle(settingsItem.getTitle() + " (" + settingsEn + ")");
    }//w  w w.jav  a2s  . c o  m
}

From source file:de.androvdr.activities.AndroVDR.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem mi = menu.findItem(R.id.androvdr_internet);
    if (Preferences.useInternet)
        mi.setTitle(R.string.main_forwarding_off);
    else// w w  w. j  a  va2 s.c  o m
        mi.setTitle(R.string.main_forwarding_on);

    boolean vdrdefined = (Preferences.getVdr() != null);
    menu.findItem(R.id.androvdr_gestures).setEnabled(vdrdefined);
    menu.findItem(R.id.androvdr_internet).setEnabled(vdrdefined);
    menu.findItem(R.id.androvdr_switch_vdr).setEnabled(vdrdefined);
    menu.findItem(R.id.androvdr_vdradmin).setEnabled(vdrdefined);
    menu.findItem(R.id.androvdr_generalstreaming).setEnabled(vdrdefined);

    if (vdrdefined) {
        menu.findItem(R.id.androvdr_vdradmin).setVisible(Preferences.getVdr().vdradmin);
        menu.findItem(R.id.androvdr_generalstreaming).setVisible(Preferences.getVdr().generalstreaming);
    }
    return true;
}

From source file:com.keylesspalace.tusky.AccountActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (!isSelf) {
        MenuItem follow = menu.findItem(R.id.action_follow);
        String title;/*from  w  w  w .  jav a  2 s  .  c  o  m*/
        if (following) {
            title = getString(R.string.action_unfollow);
        } else {
            title = getString(R.string.action_follow);
        }
        follow.setTitle(title);
        MenuItem block = menu.findItem(R.id.action_block);
        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.android.gallery3d.ingest.IngestActivity.java

private void setSwitcherMenuState(MenuItem menuItem, boolean inFullscreenMode) {
    if (menuItem == null) {
        return;/*  www .j  av a  2 s  . c om*/
    }
    if (!inFullscreenMode) {
        menuItem.setIcon(android.R.drawable.ic_menu_zoom);
        menuItem.setTitle(R.string.ingest_switch_photo_fullscreen);
    } else {
        menuItem.setIcon(android.R.drawable.ic_dialog_dialer);
        menuItem.setTitle(R.string.ingest_switch_photo_grid);
    }
}

From source file:ca.rmen.android.scrumchatter.main.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Log.v(TAG, "onPrepareOptionsMenu " + menu);
    // Only enable the "delete team" menu item if we have at least two teams.
    MenuItem deleteItem = menu.findItem(R.id.action_team_delete);
    deleteItem.setEnabled(mTeamCount > 1);
    // Add the current team name to the delete and rename menu items
    if (mTeam != null) {
        deleteItem.setTitle(getString(R.string.action_team_delete_name, mTeam.teamName));
        MenuItem renameItem = menu.findItem(R.id.action_team_rename);
        renameItem.setTitle(getString(R.string.action_team_rename_name, mTeam.teamName));
    }/* ww w .j a  v a  2  s  . c  om*/
    // Only show the settings in v14+.  Currently the only setting
    // we have is for the day/night theme switch, which only works on
    // v14+.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        MenuItem settingsItem = menu.findItem(R.id.action_settings);
        settingsItem.setVisible(false);
    }

    // Only show the menu items for sharing a meeting and stats for a meeting, if the selected meeting is finished.
    MeetingFragment meetingFragment = MeetingFragment.lookupMeetingFragment(getSupportFragmentManager());
    boolean meetingIsFinished = meetingFragment != null
            && meetingFragment.getState() == MeetingColumns.State.FINISHED;
    MenuItem menuItem = menu.findItem(R.id.action_share_meeting);
    if (menuItem != null)
        menuItem.setVisible(meetingIsFinished);
    menuItem = menu.findItem(R.id.action_charts_meeting);
    if (menuItem != null)
        menuItem.setVisible(meetingIsFinished);

    // Don't show the global share/stats menu items unless we have at least one meeting
    MeetingsListFragment meetingsListFragment = (MeetingsListFragment) mMainPagerAdapter
            .instantiateItem(mBinding.pager, 0);
    boolean hasMeetings = meetingsListFragment != null && meetingsListFragment.hasMeetings();
    menu.findItem(R.id.action_share).setVisible(hasMeetings);
    menu.findItem(R.id.action_charts).setVisible(hasMeetings);
    menuItem = menu.findItem(R.id.action_share_submenu);
    if (menuItem != null)
        menuItem.setVisible(hasMeetings);
    menuItem = menu.findItem(R.id.action_charts_submenu);
    if (menuItem != null)
        menuItem.setVisible(hasMeetings);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.gmail.taneza.ronald.carbs.main.MainActivity.java

private void setLanguageTextInOptionsMenu(Language language) {
    int languageId = (language == Language.ENGLISH) ? R.string.language_english : R.string.language_dutch;
    MenuItem languageMenuItem = mOptionsMenu.findItem(R.id.menu_language);
    languageMenuItem.setTitle(languageId);
}