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.daiki.arduino.mcheck.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
    logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);

    return super.onPrepareOptionsMenu(menu);
}

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

@Override
public void onPrepareOptionsMenu(Menu menu) {
    String subreddit = getSubreddit();

    boolean hasAccount = AccountUtils.isAccount(accountName);
    boolean hasSubreddit = subreddit != null;
    boolean hasThing = thingHolder != null && thingHolder.isShowingThing();
    boolean hasSidebar = Subreddits.hasSidebar(subreddit);
    boolean isSubreddit = hasSubreddit && !hasThing;

    boolean showNewPost = isSubreddit && hasAccount;
    boolean showSubreddit = isSubreddit && hasSidebar;
    boolean showRefresh = !hasThing;

    menu.findItem(R.id.menu_add_subreddit).setVisible(isSubreddit);
    menu.findItem(R.id.menu_new_post).setVisible(showNewPost);
    menu.findItem(R.id.menu_refresh).setVisible(showRefresh);

    MenuItem subredditItem = menu.findItem(R.id.menu_subreddit);
    subredditItem.setVisible(showSubreddit);
    if (showSubreddit) {
        subredditItem.setTitle(MenuHelper.getSubredditTitle(ctx, subreddit));
    }//from  w ww. ja v a  2 s  .c  o m
}

From source file:org.xbmc.kore.ui.AbstractListFragment.java

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

    if (gridViewUsesMultipleColumns) {
        if (PreferenceManager.getDefaultSharedPreferences(getActivity())
                .getBoolean(Settings.KEY_PREF_SINGLE_COLUMN, Settings.DEFAULT_PREF_SINGLE_COLUMN)) {
            gridView.setNumColumns(1);/*from w w  w.  java 2  s . c om*/
            adapter.notifyDataSetChanged();

            MenuItem item = menu.findItem(R.id.action_multi_single_columns);
            item.setTitle(R.string.multi_column);
        }
    } else {
        //Default number of columns for GridView is set to AUTO_FIT.
        //When this leads to a single column it is not possible
        //to switch to multiple columns. We therefore disable
        //the menu item.
        MenuItem item = menu.findItem(R.id.action_multi_single_columns);
        item.setTitle(R.string.multi_column);
        item.setEnabled(false);
    }

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.pf.MainActivity.java

private void setForwardingString(MenuItem i) {
    if (forwarding) {
        i.setTitle(titleForwarding);
    } else {/*  w w  w  . jav a 2 s .c om*/
        i.setTitle(titlePaused);
    }
}

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

private void prepareAuthorActionItem(Menu menu, int checkedCount, int position) {
    String author = adapter.getAuthor(position);
    boolean show = checkedCount == 1 && MenuHelper.isUserItemVisible(author);
    MenuItem item = menu.findItem(R.id.menu_author);
    item.setVisible(show);/* www.  j a  v  a 2  s .  c o  m*/
    if (item.isVisible()) {
        item.setTitle(MenuHelper.getUserTitle(context, author));
    }
}

From source file:com.github.kimikage.uguisuan.MainActivity.java

private void setPlayAndPauseButton() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar == null) {
        return;//from w  ww  .j  a  v a 2  s  .  co  m
    }
    if (toolbar.getMenu() == null) {
        return;
    }
    boolean playing = isPlaying();

    MenuItem menuItem = (MenuItem) toolbar.getMenu().findItem(R.id.action_play_pause);
    menuItem.setTitle(getResources().getString(playing ? R.string.action_pause : R.string.action_play));
    menuItem.setIcon(playing ? R.drawable.ic_pause_circle_filled_white_48dp
            : R.drawable.ic_play_circle_filled_white_48dp);
    View v = findViewById(R.id.action_play_pause);
    if (v != null) {
        v.setSoundEffectsEnabled(playing);
    }
}

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

private void prepareAboutItem(Menu menu, ListView lv, boolean visible) {
    MenuItem item = menu.findItem(R.id.menu_subreddit);
    item.setVisible(visible);//from   w w  w  .j a v  a  2  s .  c om
    if (visible) {
        item.setTitle(ctx.getString(R.string.menu_subreddit, getFirstCheckedSubreddit(lv)));
    }
}

From source file:uk.co.senab.photoview.sample.SimpleSampleActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem zoomToggle = menu.findItem(R.id.menu_zoom_toggle);
    assert null != zoomToggle;
    zoomToggle.setTitle(mAttacher.canZoom() ? R.string.menu_zoom_disable : R.string.menu_zoom_enable);

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.videolan.myvlc.core.widget.AudioMiniPlayerFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.audio_player_mini, menu);

    MenuItem pp = menu.findItem(R.id.play_pause);
    if (mAudioPlayerControl.isPlaying()) {
        pp.setTitle(R.string.pause);
    } else {//from  w  w  w  . j ava2 s  . c  om
        pp.setTitle(R.string.play);
    }
}

From source file:sean.dataexchange.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    logToggle.setTitle(mLogShown ? R.string.survey : R.string.map);
    return super.onPrepareOptionsMenu(menu);
}