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.janela.mobile.ui.gist.GistFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    boolean owner = isOwner();
    if (!owner) {
        menu.removeItem(R.id.m_delete);//from w w w . j av a2 s .c  o m
        MenuItem starItem = menu.findItem(R.id.m_star);
        starItem.setEnabled(loadFinished && !owner);
        if (starred)
            starItem.setTitle(R.string.unstar);
        else
            starItem.setTitle(R.string.star);
    } else
        menu.removeItem(R.id.m_star);
}

From source file:com.fastbootmobile.encore.app.AlbumActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.album, menu);

    // Keep in tune with the XML!
    final ProviderAggregator aggregator = ProviderAggregator.getDefault();
    final Runnable updateMenuArtist = new Runnable() {
        @Override//from  www. j a  va  2s  . co m
        public void run() {
            String artistRef = mActiveFragment.getArtist();
            MenuItem item = menu.getItem(2);

            if (artistRef != null) {
                final Artist artist = aggregator.retrieveArtist(artistRef,
                        mActiveFragment.getAlbum().getProvider());
                if (artist != null) {
                    item.setTitle(getString(R.string.more_from, artist.getName()));
                    item.setVisible(true);
                }
            } else {
                // We don't have the tracks for that album yet, try again.
                mHandler.postDelayed(this, 1000);
                item.setVisible(false);
            }
        }
    };
    updateMenuArtist.run();

    return true;
}

From source file:edu.berkeley.boinc.ProjectDetailsFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    super.onPrepareOptionsMenu(menu);
    if (project == null)
        return;//from w ww .  ja va2s .  com

    // no new tasks, adapt based on status 
    MenuItem nnt = menu.findItem(R.id.projects_control_nonewtasks);
    if (project.dont_request_more_work)
        nnt.setTitle(R.string.projects_control_allownewtasks);
    else
        nnt.setTitle(R.string.projects_control_nonewtasks);

    // project suspension, adapt based on status 
    MenuItem suspend = menu.findItem(R.id.projects_control_suspend);
    if (project.suspended_via_gui)
        suspend.setTitle(R.string.projects_control_resume);
    else
        suspend.setTitle(R.string.projects_control_suspend);

    // detach, only show when project not managed
    MenuItem remove = menu.findItem(R.id.projects_control_remove);
    if (project.attached_via_acct_mgr)
        remove.setVisible(false);
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        // Intent intent = new Intent(this, PreferencesActivity.class);
        // startActivityForResult(intent, REQUEST_PREFERENCE);
        return true;
    case R.id.connect:

        if (!this.isConnected)
            connectBt();/*from w ww .j  a v a 2  s . c  om*/
        else
            shutdownBt();

        item.setTitle(!this.isConnected ? "Connect" : "Disconnect");

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

From source file:com.byteshaft.licenseservice.StartTestActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_instant_questions);
    if (Helpers.isInstantAnswerEnabled()) {
        menuItem.setTitle("Disable Instant Answer");
    } else {/* ww  w  .  j  ava 2  s . c o m*/
        menuItem.setTitle("Enable Instant Answer");
    }
    return true;

}

From source file:com.fastaccess.ui.modules.repos.RepoPagerView.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);//  ww  w  .  ja v a 2 s  .  co  m
        menuItem.setTitle(repoModel.getParent().getFullName());
    }
    //        menu.findItem(R.id.deleteRepo).setVisible(getPresenter().isRepoOwner());
    menu.findItem(R.id.deleteRepo).setVisible(false);//removing delete permission.
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl.java

private void createNavDrawerItems(NavigationModel.NavigationItemEnum[] items) {
    if (mNavigationView != null) {
        Menu menu = mNavigationView.getMenu();
        for (int i = 0; i < items.length; i++) {
            MenuItem item = menu.findItem(items[i].getId());
            if (item != null) {
                item.setVisible(true);//from   w w w.j  a v a 2s  . c o m
                item.setIcon(items[i].getIconResource());
                item.setTitle(items[i].getTitleResource());
            } else {
                LOGE(TAG,
                        "Menu Item for navigation item with title " + (items[i].getTitleResource() != 0
                                ? mActivity.getResources().getString(items[i].getTitleResource())
                                : "") + "not found");
            }
        }

        mNavigationView.setNavigationItemSelectedListener(this);
    }
}

From source file:org.gnucash.android.ui.export.ExportFormFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.default_save_actions, menu);
    MenuItem menuItem = menu.findItem(R.id.menu_save);
    menuItem.setTitle(R.string.btn_export);
}

From source file:app.CT.BTCCalculator.fragments.BreakevenFragment.java

private void updateMenuTitles() {
    MenuItem buy = menu.findItem(R.id.editCurrentBuyField);
    MenuItem sell = menu.findItem(R.id.editCurrentSellField);

    if (containsCurrentRate[0])
        buy.setTitle(R.string.removeBuyField);
    else/*from w w  w  .j  a  v a  2 s  .co m*/
        buy.setTitle(R.string.addBuyField);

    if (containsCurrentRate[1])
        sell.setTitle(R.string.removeSellField);
    else
        sell.setTitle(R.string.addSellField);
}

From source file:com.josecarlos.couplecounters.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    getMenuInflater().inflate(R.menu.menu_counter, menu);
    MenuItem item = (MenuItem) menu.findItem(R.id.counter_change);
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (listAdapter.getItem(info.position).isCommon()) {
        item.setTitle("make individual counter");
    } else//w  w w  .  j  a v a 2 s.  c  om
        item.setTitle("make common counter");
    super.onCreateContextMenu(menu, v, menuInfo);
}