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:fr.kwiatkowski.apktrack.MainActivity.java

private boolean _toggle_sort(MenuItem item) {
    // The user's choice is stored as a preference.
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String sort_type = pref.getString(SettingsFragment.KEY_PREF_SORT_TYPE, SettingsFragment.ALPHA_SORT);
    if (sort_type.equals(SettingsFragment.ALPHA_SORT)) {
        Log.v(MainActivity.TAG, "Sorting apps by status.");
        item.setTitle(R.string.sort_type_alpha);
        pref.edit().putString(SettingsFragment.KEY_PREF_SORT_TYPE, SettingsFragment.STATUS_SORT).apply();
        _app_display.sort();//from  w ww.  java  2 s. c  o  m
    } else {
        Log.v(MainActivity.TAG, "Sorting apps by alphabetical order.");
        item.setTitle(R.string.sort_type_updated);
        pref.edit().putString(SettingsFragment.KEY_PREF_SORT_TYPE, SettingsFragment.ALPHA_SORT).apply();
        _app_display.sort();
    }
    return true;
}

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

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (Logging.DEBUG)
        Log.d(Logging.TAG, "BOINCActivity onPrepareOptionsMenu()");

    // run mode, set title and icon based on status
    MenuItem runMode = menu.findItem(R.id.run_mode);
    if (clientComputingStatus == ClientStatus.COMPUTING_STATUS_NEVER) {
        // display play button
        runMode.setTitle(R.string.menu_run_mode_enable);
        runMode.setIcon(R.drawable.playw);
    } else {//from  w  w  w.  ja v  a 2s .  co  m
        // display stop button
        runMode.setTitle(R.string.menu_run_mode_disable);
        runMode.setIcon(R.drawable.pausew);
    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.catnut.ui.HelloActivity.java

public void onMenuItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.toggle_fantasy:
        int i = mViewPager.getCurrentItem();
        if (i == 0) {
            if (mAbout.getVisibility() == View.VISIBLE) {
                mAbout.setVisibility(View.GONE);
                item.setTitle(R.string.show_fantasy_words).setIcon(R.drawable.ic_action_fullscreen_off);
            } else {
                mAbout.setVisibility(View.VISIBLE);
                item.setTitle(R.string.hide_fantasy_words).setIcon(R.drawable.ic_action_fullscreen_on);
            }//from ww  w .j  a v  a  2 s. com
        } else {
            if (mFantasyDesc.getVisibility() == View.VISIBLE) {
                mFantasyDesc.setVisibility(View.GONE);
                item.setTitle(R.string.show_fantasy_words).setIcon(R.drawable.ic_action_fullscreen_off);
            } else {
                mFantasyDesc.setVisibility(View.VISIBLE);
                item.setTitle(R.string.hide_fantasy_words).setIcon(R.drawable.ic_action_fullscreen_on);
            }
        }
        break;
    case android.R.id.home:
        Intent intent = getIntent();
        if (Intent.ACTION_MAIN.equals(intent.getAction())) {
            startActivity(new Intent(this, MainActivity.class));
        } else {
            navigateUpTo(intent);
        }
        break;
    case R.id.home:
        startActivity(new Intent(this, MainActivity.class));
        break;
    default:
        break;
    }
}

From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.sessions_context, menu);
    MenuItem starMenuItem = menu.findItem(R.id.menu_star);
    starMenuItem.setTitle(R.string.description_remove_schedule);
    starMenuItem.setIcon(R.drawable.ic_action_remove_schedule);
    mAdapter.notifyDataSetChanged();//from  w w w  . ja v a  2  s  . co  m
    mActionModeStarted = true;
    return true;
}

From source file:com.app.uafeed.fragment.EntryFragment.java

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

    if (mFavorite) {
        MenuItem item = menu.findItem(R.id.menu_star);
        item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important);
    }//ww  w .  j a v a2s .  co m

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:il.ac.shenkar.todos.view.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.context_menu, menu);
    menu.setHeaderTitle("Task Menu");

    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    // stores current item position
    int position = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    // current task description
    String taskDescription = taskListModel.getTaskAt(position).getTaskDescription();
    // is task marked as important
    boolean isImportant = taskListModel.getTaskAt(position).isImportant();

    if (Utils.ENGLISH_LANGUAGE == false) {
        // make hebrew menu
        menu.setHeaderTitle(" ");
        Utils.makeHebrewContextMenu(menu);

        if (taskDescription.equals(Utils.DEFAULT_DESCRIPTION)) {
            MenuItem item = menu.findItem(R.id.editDescription);
            item.setTitle(" ");
        }/*from w w w  .  j a va2 s.co  m*/
        if (isImportant) {
            MenuItem item = menu.findItem(R.id.markImportant);
            item.setTitle(" - ");
        }
    } else {
        // checks if description is empty
        if (taskDescription.equals(Utils.DEFAULT_DESCRIPTION)) {
            MenuItem item = menu.findItem(R.id.editDescription);
            item.setTitle("Add Task Description");
        }

        if (isImportant) {
            MenuItem item = menu.findItem(R.id.markImportant);
            item.setTitle("Mark As Unimportant");
        }
    }
}

From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item;

    item = menu.findItem(R.id.OrderByName);
    if (item != null) {
        if (mOrderByName)
            item.setTitle(getString(R.string.OrderByLevel));
        else//from  www  . j  a v a 2 s.c  o m
            item.setTitle(getString(R.string.OrderByName));
    }

    EquipmentListView elv;

    item = menu.findItem(R.id.FilterByType);
    SubMenu submenu = item.getSubMenu();
    submenu.removeGroup(R.id.FilterByType);

    elv = (EquipmentListView) findViewById(R.id.ListView);
    if (elv != null) {
        String types[] = elv.getAvailableWeaponTypes();

        if (types == null || types.length == 1) {
            item.setEnabled(false);
        } else {
            item.setEnabled(true);
            submenu.add(R.id.FilterByType, -1, Menu.NONE, getString(R.string.ResetFilterByType));
            for (int i = 0; i < types.length; i++) {
                submenu.add(R.id.FilterByType, i, Menu.NONE, types[i]);
            }
        }

    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.leopub.mat.controller.PersonalInfoActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.personal_info, menu);
    MenuItem menuItem = menu.findItem(R.id.person_name);
    if (mUnderlingList.size() == 0) {
        menuItem.setVisible(false);// ww  w .j  av  a2s  .c o m
    } else {
        menuItem.setTitle(mChosenPerson.getName());
    }
    return true;
}

From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

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

    final NetworkTree tree = getCurrentTree();
    for (Action a : myOptionsMenuActions) {
        final MenuItem item = menu.findItem(a.Code);
        if (a.isVisible(tree)) {
            item.setVisible(true);//from w  w  w  .ja  va2 s.  co m
            item.setEnabled(a.isEnabled(tree));
            item.setTitle(a.getOptionsLabel(tree));
        } else {
            item.setVisible(false);
        }
    }
    return true;
}

From source file:com.ptr.folding.sample.FoldingLayoutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.animate_fold:
        animateFold();//from   ww  w  . ja va 2 s.  c  om
        break;
    case R.id.toggle_orientation:
        mOrientation = (mOrientation == Orientation.HORIZONTAL) ? Orientation.VERTICAL : Orientation.HORIZONTAL;
        item.setTitle((mOrientation == Orientation.HORIZONTAL) ? R.string.vertical : R.string.horizontal);
        // mTranslation = 0;
        mFoldLayout.setOrientation(mOrientation);
        break;
    case R.id.camera_feed:
        if (IS_ISC) {
            mIsCameraFeed = !mIsCameraFeed;
            item.setTitle(mIsCameraFeed ? R.string.static_image : R.string.camera_feed);
            item.setChecked(mIsCameraFeed);
            if (mIsCameraFeed) {
                //   mFoldLayout.removeView(mImageView);
                //   mFoldLayout.addView(mTextureView,
                //      new ViewGroup.LayoutParams(mFoldLayout.getWidth(),
                //            mFoldLayout.getHeight()));
            } else {
                //mFoldLayout.removeView(mTextureView);
                //mFoldLayout.addView(mImageView, new ViewGroup.LayoutParams(
                //      mFoldLayout.getWidth(), mFoldLayout.getHeight()));
            }
            // mTranslation = 0;
        }
        break;
    case R.id.sepia:
        mIsSepiaOn = !mIsSepiaOn;
        item.setChecked(mIsSepiaOn);
        if (mIsSepiaOn && mFoldLayout.getFoldFactor() != 0) {
            setSepiaLayer(mFoldLayout.getChildAt(0), true);
        } else {
            setSepiaLayer(mFoldLayout.getChildAt(0), false);
        }
        break;
    default:
        break;

    }
    return super.onOptionsItemSelected(item);
}