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.translationexchange.samples.wammer.activities.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // if nav drawer is opened, hide the action items
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
    MenuItem menuItem = (MenuItem) menu.findItem(R.id.change_language);
    menuItem.setVisible(!drawerOpen);/*from w  ww  . j  a  v a  2s  .  c  o  m*/
    menuItem.setTitle("Change Language");
    menuItem = (MenuItem) menu.findItem(R.id.inline_translator);
    menuItem.setVisible(!drawerOpen);
    menuItem.setTitle("Translate");
    return super.onPrepareOptionsMenu(menu);
}

From source file:org.getlantern.firetweet.fragment.support.SearchFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    final MenuItem item = menu.findItem(MENU_COMPOSE);
    item.setTitle(getString(R.string.tweet_hashtag, getQuery()));
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_overview_fragment, menu);
    menu.findItem(R.id.action_boomark).setVisible(prefHelper.getBookmark() != 0)
            .setTitle(R.string.open_bookmark);
    menu.findItem(R.id.action_hide_read).setChecked(prefHelper.hideRead());
    menu.findItem(R.id.action_search).setVisible(false);
    menu.findItem(R.id.action_boomark).setVisible(bookmark != 0);

    MenuItem fav = menu.findItem(R.id.action_favorite);
    if (!prefHelper.overviewFav()) {
        fav.setIcon(R.drawable.ic_favorite_outline);
        fav.setTitle(R.string.nv_favorites);
    } else {/*from   www  .  ja v a2 s . com*/
        fav.setIcon(R.drawable.ic_action_favorite);
        fav.setTitle(R.string.action_overview);
    }

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.cforlando.streetartandroid.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_logout);
    if (ParseUser.getCurrentUser() == null) {
        menuItem.setTitle(R.string.sign_in);
    } else {//from   w ww.  j  a  va  2s  .  c  om
        menuItem.setTitle(R.string.sign_out);
    }
    return true;
}

From source file:com.meetingninja.csse.agenda.AgendaActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    final MenuItem collapsibleMenu = menu.findItem(R.id.collapsible_menu_item);
    if (collapsible) {
        collapsibleMenu.setTitle(R.string.collapsible_menu_disable);
        collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_disable));
        collapsibleMenu.setChecked(collapsible);
    } else {/* www.  ja  v  a 2 s  .c  om*/
        collapsibleMenu.setTitle(R.string.collapsible_menu_enable);
        collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_enable));
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.joncairo.android.todo.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // get the checked/unchecked counts and number of archived/unarchived items
    MenuItem totalTodos = menu.findItem(R.id.total_todos);
    totalTodos.setTitle("Total Todos: " + Integer.toString(mtoDoFragment.mTodos.size()));
    ArrayList<Integer> checkedAndUncheckedTotals = mtoDoFragment.totalCheckedAndUncheckedItems();
    MenuItem totalTodosUnchecked = menu.findItem(R.id.total_unchecked_todos);
    MenuItem totalTodosChecked = menu.findItem(R.id.total_checked_todos);
    totalTodosChecked.setTitle("Todos Checked: " + Integer.toString(checkedAndUncheckedTotals.get(0)));
    totalTodosUnchecked.setTitle("Todos Unchecked: " + Integer.toString(checkedAndUncheckedTotals.get(1)));

    MenuItem totalArchivedTodos = menu.findItem(R.id.total_archived);
    totalArchivedTodos.setTitle("Total Archived: " + Integer.toString(mArchivedToDoFragment.mTodos.size()));
    ArrayList<Integer> checkedAndUncheckedArchivedTotals = mArchivedToDoFragment
            .totalCheckedAndUncheckedItems();
    MenuItem totalArchivedTodosChecked = menu.findItem(R.id.total_checked_archived);
    MenuItem totalArchivedTodosUnchecked = menu.findItem(R.id.total_unchecked_archived);
    totalArchivedTodosChecked/*w  ww  . j a  v  a  2  s . co  m*/
            .setTitle("Archived Checked: " + Integer.toString(checkedAndUncheckedArchivedTotals.get(0)));
    totalArchivedTodosUnchecked
            .setTitle("Archived Unchecked: " + Integer.toString(checkedAndUncheckedArchivedTotals.get(1)));
    return true;
}

From source file:st.ghostca.ghostcast.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.iaraby.template.view.Master_Activity.java

public void updateFavButton(long selectedId) {
    if (menu != null && selectedId != Constants.EMPTY_INT) {
        MenuItem favItem = menu.findItem(R.id.action_fav);
        if (FavoriteManager.getInstance(this).isFav(selectedId)) {
            favItem.setTitle(getString(R.string.action_fav));
            favItem.setIcon(R.drawable.menu_item_fav);
        } else {// w w  w  . ja va 2s .co  m
            favItem.setTitle(getString(R.string.action_not_fav));
            favItem.setIcon(R.drawable.menu_item_not_fav);
        } // check if selected item favorite or not
    } // make sure menu item not null
}

From source file:com.by_syk.lib.nanoiconpack.MainActivity.java

@Override
public void onLoadDone(int pageId, int sum) {
    MenuItem menuItem = bottomNavigationView.getMenu().getItem(pageId);
    switch (pageId) {
    case 0://from w  ww .j  a  v a2 s.c  om
        menuItem.setTitle(getString(R.string.nav_lost) + "(" + sum + ")");
        break;
    case 1:
        menuItem.setTitle(getString(R.string.nav_matched) + "(" + sum + ")");
        break;
    case 2:
        menuItem.setTitle(getString(R.string.nav_all) + "(" + sum + ")");
        break;
    }
}

From source file:de.egore911.drilog.ShowActivity.java

public void updateDateText(String text) {
    if (mMenu != null) {
        MenuItem item = mMenu.findItem(R.id.choose_date);
        item.setTitle(text);
    }//from  w w w  . j  a va  2s  .co m
}