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:de.grobox.liberario.utils.TransportrUtils.java

static public void setFavState(Context context, MenuItem item, boolean is_fav, boolean is_toolbar) {
    if (is_fav) {
        item.setTitle(R.string.action_unfav_trip);
        item.setIcon(is_toolbar ? getToolbarDrawable(context, R.drawable.ic_action_star)
                : getTintedDrawable(context, R.drawable.ic_action_star));
    } else {//from www  .  j  a  va2s.  c  o m
        item.setTitle(R.string.action_fav_trip);
        item.setIcon(is_toolbar ? getToolbarDrawable(context, R.drawable.ic_action_star_empty)
                : getTintedDrawable(context, R.drawable.ic_action_star_empty));
    }
}

From source file:com.example.android.storageprovider.MyCloudFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem item = menu.findItem(R.id.sample_action);
    item.setTitle(mLoggedIn ? R.string.log_out : R.string.log_in);
}

From source file:de.grobox.transportr.favorites.trips.FavoriteTripPopupMenu.java

private void setFavState(MenuItem item, boolean is_fav) {
    if (is_fav) {
        item.setTitle(R.string.action_unfav_trip);
        item.setIcon(R.drawable.ic_action_star_empty);
        DrawableCompat.setTint(item.getIcon(), iconColor);
    } else {//from   w  w w  . j  a v a  2 s  . c om
        item.setTitle(R.string.action_fav_trip);
        item.setIcon(R.drawable.ic_action_star);
        DrawableCompat.setTint(item.getIcon(), iconColor);
    }
}

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

@Override
public void onPrepareOptionsMenu(Menu menu) {
    if (isDetached() || getActivity() == null)
        return;/*from w  w  w .  ja va2s  .  c om*/
    final MenuItem item = menu.findItem(R.id.compose);
    item.setTitle(getString(R.string.tweet_hashtag, getQuery()));
}

From source file:com.heron.btcommand.Main.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem connectItem = menu.findItem(R.id.connect);
    connectItem.setTitle(!this.isConnected ? "Connect" : "Disconnect");

    return super.onPrepareOptionsMenu(menu);
}

From source file:com.example.android.storageprovider.MyCloudFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.sample_action) {
        toggleLogin();/*from  w  w  w .  ja v  a 2 s  .c  o m*/
        item.setTitle(mLoggedIn ? R.string.log_out : R.string.log_in);

        // BEGIN_INCLUDE(notify_change)
        // Notify the system that the status of our roots has changed.  This will trigger
        // a call to MyCloudProvider.queryRoots() and force a refresh of the system
        // picker UI.  It's important to call this or stale results may persist.
        getActivity().getContentResolver().notifyChange(DocumentsContract.buildRootsUri(AUTHORITY), null,
                false);
        // END_INCLUDE(notify_change)
    }
    return true;
}

From source file:com.bellman.bible.android.view.activity.base.actionbar.QuickActionButton.java

protected void update(MenuItem menuItem) {
    // canShow means must show because we rely on AB logic
    menuItem.setVisible(canShow());//from  ww w .ja  v  a  2s. co m

    menuItem.setTitle(getTitle());

    int iconResId = getIcon();
    if (iconResId != NO_ICON) {
        menuItem.setIcon(iconResId);
    }
}

From source file:net.lacolaco.smileessence.activity.EditCommandActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem allOn = menu.add(Menu.NONE, R.id.menu_edit_command_all_on, Menu.NONE, "");
    allOn.setTitle(R.string.actionbar_edit_command_all_on);
    allOn.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;/*  ww w  . ja v  a  2s .co  m*/
}

From source file:com.example.weix.bluetooth_receive.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_show_log : R.string.sample_hide_log);

    return super.onPrepareOptionsMenu(menu);
}

From source file:shantanu.housemate.bluetoothchat.BluetoothActivity.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 ? "Hide Log" : "Show Log");
    return super.onPrepareOptionsMenu(menu);
}