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:ru.appsm.inapphelp.fragments.NewIssueFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.iah_issue_menu, menu);

    MenuItem clearMenu = menu.findItem(R.id.clearItem);
    MenuItemCompat.setShowAsAction(clearMenu, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);

    MenuItem doneMenu = menu.findItem(R.id.doneItem);

    doneMenu.setIcon(getResources().getDrawable(R.drawable.iah_action_forward));
    doneMenu.setTitle(getResources().getText(R.string.iah_next));

    MenuItemCompat.setShowAsAction(doneMenu, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}

From source file:org.sigimera.app.android.MainActivity.java

@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    MenuItem itemUpdateLocation = menu.findItem(R.id.menu_update_location);
    itemUpdateLocation.setTitle("Update your location");

    MenuItem itemUpdateEverything = menu.findItem(R.id.menu_update_everything);
    itemUpdateEverything.setTitle("Update everything");
    return super.onCreateOptionsMenu(menu);
}

From source file:task.application.com.colette.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);// w  w  w.  j av a 2 s  . c o m
                item.setIcon(items[i].getIcon());
                item.setTitle(items[i].getTitleResource());
            } else {
                LogUtils.LOGE(TAG,
                        "Menu Item for navigation item with title " + (items[i].getTitleResource() != 0
                                ? mActivity.getResources().getString(items[i].getTitleResource())
                                : "") + "not found");
            }
        }

        for (int i = 0; i < menu.size(); i++) {
            MenuItem mi = menu.getItem(i);
            applyFontToSubMenu(mi);
            applyFontToMenuItem(mi);
        }

        mNavigationView.setNavigationItemSelectedListener(this);
    }
}

From source file:com.example.haber.ui.activity.CallActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_call_activity, menu);
    MenuItem itemBW = menu.getItem(0);
    itemBW.setTitle("" + currentDefaultBW);
    return true;/*from ww w  . j av  a2 s.c  om*/
}

From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    // We change the look of the icon every time the user toggles between list and grid.
    MenuItem item = menu.findItem(R.id.action_toggle);
    if (null != item) {
        if (mAbsListView instanceof ListView) {
            item.setIcon(R.drawable.ic_action_grid);
            item.setTitle(R.string.show_as_grid);
        } else {//from  w  w  w  .  ja  va  2  s .c om
            item.setIcon(R.drawable.ic_action_list);
            item.setTitle(R.string.show_as_list);
        }
    }
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

public static void setPartyShuffleMenuIcon(Menu menu) {
    MenuItem item = menu.findItem(Defs.PARTY_SHUFFLE);
    if (item != null) {
        int shuffle = MusicUtils.getCurrentShuffleMode();
        if (shuffle == MediaPlaybackService.SHUFFLE_AUTO) {
            item.setIcon(R.drawable.ic_menu_party_shuffle);
            item.setTitle(R.string.party_shuffle_off);
        } else {//w w  w.  j av  a 2 s  .c om
            item.setIcon(R.drawable.ic_menu_party_shuffle);
            item.setTitle(R.string.party_shuffle);
        }
    }
}

From source file:us.phyxsi.gameshelf.ui.HomeActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem bggLogin = menu.findItem(R.id.menu_import);
    if (bggLogin != null) {
        bggLogin.setTitle(bggPrefs.isLoggedIn() ? R.string.bgg_log_out : R.string.bgg_login);
    }/* ww  w.  j  a v  a 2s . co  m*/

    return true;
}

From source file:com.itime.team.itime.fragments.InboxFragment.java

private void setItemTitle(MenuItem item) {
    switch (mStatus) {
    case UNREAD://from w  w w.  j a  v a  2  s  . c  o m
        item.setTitle(getString(R.string.all_message));
        break;

    case ALL:
        item.setTitle(getString(R.string.unread));
        break;
    }
}

From source file:cn.yibulz.caviewtest.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.switch_flash:
        if (mCameraView != null) {
            mCurrentFlash = (mCurrentFlash + 1) % FLASH_OPTIONS.length;
            item.setTitle(FLASH_TITLES[mCurrentFlash]);
            item.setIcon(FLASH_ICONS[mCurrentFlash]);
            mCameraView.setFlash(FLASH_OPTIONS[mCurrentFlash]);
        }//from w w w .j ava 2  s  .  com
        break;
    case R.id.switch_camera:
        if (mCameraView != null) {
            int facing = mCameraView.getFacing();
            mCameraView.setFacing(
                    facing == CameraView.FACING_FRONT ? CameraView.FACING_BACK : CameraView.FACING_FRONT);
        }
        break;
    }
    return false;
}

From source file:ng.uavp.ch.ngusbterminal.MainActivity.java

@Override
public void onConfirmSelect(int actionID, String absolutePath, String fileName) {
    // Cancel pressed
    if (fileName == "") {
        ShowTab(selectedTab);/*from   w w  w  .  j a v  a  2s  .  co m*/
        return;
    }

    switch (actionID) {
    case ACTION_READFILE:
        if (!isExternalStorageReadable()) {
            showToast(R.string.err_sd_not_readable, Toast.LENGTH_SHORT);
            return;
        }
        try {
            File inputFile = new File(absolutePath, fileName);
            BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(inputFile));
            byte[] buffer = new byte[(int) inputFile.length()];
            inputStream.read(buffer);
            inputStream.close();
            usb.sendBytes(buffer);
        } catch (FileNotFoundException e1) {
            showToast(e1.getMessage(), Toast.LENGTH_SHORT);
        } catch (IOException e2) {
            showToast(e2.getMessage(), Toast.LENGTH_SHORT);
        }
        break;

    case ACTION_WRITEFILE: {
        if (!isExternalStorageWritable()) {
            showToast(R.string.err_sd_not_writeable, Toast.LENGTH_SHORT);
            return;
        }
        try {
            logtofile.StartWritingToFile(absolutePath, fileName);

            MenuItem item = menu.findItem(R.id.menu_writefile);
            item.setTitle(R.string.action_stop_log);
            item.setIcon(R.drawable.ic_doc_stop_save);

            String str = getString(R.string.action_start_log) + " " + fileName;
            showToast(str, Toast.LENGTH_SHORT);
        } catch (Exception e) {
            showToast(e.getMessage(), Toast.LENGTH_SHORT);
        }
        break;
    }
    }
    ShowTab(selectedTab);
}