List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:tw.com.geminihsu.app01.fragment.Fragment_OrderFilter.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FINISH, Menu.NONE, getString(R.string.btn_finish)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.f16gaming.pathofexilestatistics.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem toggleItem = menu.findItem(R.id.menu_toggle); toggleItem.setTitle(showHardcore ? R.string.menu_normal : R.string.menu_hardcore); return true;//from w ww . ja v a2 s .c o m }
From source file:org.xbmc.kore.ui.AbstractListFragment.java
private void toggleAmountOfColumns(MenuItem item) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit(); if (gridView.getNumColumns() == 1) { editor.putBoolean(Settings.KEY_PREF_SINGLE_COLUMN, false); item.setTitle(R.string.single_column); gridView.setNumColumns(GridView.AUTO_FIT); } else {//from ww w.ja v a 2 s . c o m editor.putBoolean(Settings.KEY_PREF_SINGLE_COLUMN, true); item.setTitle(R.string.multi_column); gridView.setNumColumns(1); } editor.apply(); adapter.notifyDataSetChanged(); //force gridView to redraw }
From source file:de.tap.easy_xkcd.fragments.FavoritesFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.action_latest).setVisible(false); menu.findItem(R.id.action_search).setVisible(false); menu.findItem(R.id.action_boomark).setVisible(false); menu.findItem(R.id.action_overview).setVisible(false); menu.findItem(R.id.delete_favorites).setVisible(true); MenuItem fav = menu.findItem(R.id.action_favorite); fav.setIcon(R.drawable.ic_action_favorite); fav.setTitle(R.string.action_favorite_remove); //If the FAB is visible, hide the random comic menu item if (((MainActivity) getActivity()).getFab().getVisibility() == View.GONE) { menu.findItem(R.id.action_random).setVisible(true); } else {/*from w w w. jav a2 s. c om*/ menu.findItem(R.id.action_random).setVisible(false); } }
From source file:com.github.pockethub.ui.commit.CommitFileViewActivity.java
@Override public boolean onCreateOptionsMenu(final Menu optionsMenu) { getMenuInflater().inflate(R.menu.file_view, optionsMenu); MenuItem wrapItem = optionsMenu.findItem(R.id.m_wrap); if (PreferenceUtils.getCodePreferences(this).getBoolean(WRAP, false)) wrapItem.setTitle(R.string.disable_wrapping); else/*from w w w .j a v a2 s . c o m*/ wrapItem.setTitle(R.string.enable_wrapping); markdownItem = optionsMenu.findItem(R.id.m_render_markdown); if (isMarkdownFile) { markdownItem.setEnabled(blob != null); markdownItem.setVisible(true); if (PreferenceUtils.getCodePreferences(this).getBoolean(RENDER_MARKDOWN, true)) markdownItem.setTitle(R.string.show_raw_markdown); else markdownItem.setTitle(R.string.render_markdown); } return true; }
From source file:com.github.pockethub.ui.commit.CommitFileViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.m_wrap: if (editor.getWrap()) item.setTitle(R.string.enable_wrapping); else//from w w w . ja va 2 s .c o m item.setTitle(R.string.disable_wrapping); editor.toggleWrap(); PreferenceUtils .save(PreferenceUtils.getCodePreferences(this).edit().putBoolean(WRAP, editor.getWrap())); return true; case R.id.m_share: shareFile(); return true; case R.id.m_render_markdown: if (editor.isMarkdown()) { item.setTitle(R.string.render_markdown); editor.toggleMarkdown(); editor.setSource(file, blob); } else { item.setTitle(R.string.show_raw_markdown); editor.toggleMarkdown(); if (renderedMarkdown != null) editor.setSource(file, renderedMarkdown, false); else loadMarkdown(); } PreferenceUtils.save(PreferenceUtils.getCodePreferences(this).edit().putBoolean(RENDER_MARKDOWN, editor.isMarkdown())); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.example.android.bluetoothchat.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.github.chrisbanes.photoview.sample.SimpleSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("Simple Sample"); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//ww w .j a v a 2 s. c om public void onClick(View v) { onBackPressed(); } }); toolbar.inflateMenu(R.menu.main_menu); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_zoom_toggle: mPhotoView.setZoomable(!mPhotoView.isZoomEnabled()); item.setTitle( mPhotoView.isZoomEnabled() ? R.string.menu_zoom_disable : R.string.menu_zoom_enable); return true; case R.id.menu_scale_fit_center: mPhotoView.setScaleType(ImageView.ScaleType.CENTER); return true; case R.id.menu_scale_fit_start: mPhotoView.setScaleType(ImageView.ScaleType.FIT_START); return true; case R.id.menu_scale_fit_end: mPhotoView.setScaleType(ImageView.ScaleType.FIT_END); return true; case R.id.menu_scale_fit_xy: mPhotoView.setScaleType(ImageView.ScaleType.FIT_XY); return true; case R.id.menu_scale_scale_center: mPhotoView.setScaleType(ImageView.ScaleType.CENTER); return true; case R.id.menu_scale_scale_center_crop: mPhotoView.setScaleType(ImageView.ScaleType.CENTER_CROP); return true; case R.id.menu_scale_scale_center_inside: mPhotoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); return true; case R.id.menu_scale_random_animate: case R.id.menu_scale_random: Random r = new Random(); float minScale = mPhotoView.getMinimumScale(); float maxScale = mPhotoView.getMaximumScale(); float randomScale = minScale + (r.nextFloat() * (maxScale - minScale)); mPhotoView.setScale(randomScale, item.getItemId() == R.id.menu_scale_random_animate); showToast(String.format(SCALE_TOAST_STRING, randomScale)); return true; case R.id.menu_matrix_restore: if (mCurrentDisplayMatrix == null) showToast("You need to capture display matrix first"); else mPhotoView.setDisplayMatrix(mCurrentDisplayMatrix); return true; case R.id.menu_matrix_capture: mCurrentDisplayMatrix = new Matrix(); mPhotoView.getDisplayMatrix(mCurrentDisplayMatrix); return true; } return false; } }); mPhotoView = (PhotoView) findViewById(R.id.iv_photo); mCurrMatrixTv = (TextView) findViewById(R.id.tv_current_matrix); Drawable bitmap = ContextCompat.getDrawable(this, R.drawable.wallpaper); mPhotoView.setImageDrawable(bitmap); // Lets attach some listeners, not required though! mPhotoView.setOnMatrixChangeListener(new MatrixChangeListener()); mPhotoView.setOnPhotoTapListener(new PhotoTapListener()); mPhotoView.setOnSingleFlingListener(new SingleFlingListener()); }
From source file:com.github.pockethub.android.ui.commit.CommitFileViewActivity.java
@Override public boolean onCreateOptionsMenu(final Menu optionsMenu) { getMenuInflater().inflate(R.menu.activity_file_view, optionsMenu); MenuItem wrapItem = optionsMenu.findItem(R.id.m_wrap); if (PreferenceUtils.getCodePreferences(this).getBoolean(WRAP, false)) { wrapItem.setTitle(R.string.disable_wrapping); } else {/*from w w w . j a v a 2 s. c om*/ wrapItem.setTitle(R.string.enable_wrapping); } markdownItem = optionsMenu.findItem(R.id.m_render_markdown); if (isMarkdownFile) { markdownItem.setEnabled(blob != null); markdownItem.setVisible(true); if (PreferenceUtils.getCodePreferences(this).getBoolean(RENDER_MARKDOWN, true)) { markdownItem.setTitle(R.string.show_raw_markdown); } else { markdownItem.setTitle(R.string.render_markdown); } } return true; }
From source file:com.github.pockethub.android.ui.commit.CommitFileViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.m_wrap: if (editor.getWrap()) { item.setTitle(R.string.enable_wrapping); } else {/*from w ww. j a v a 2s. com*/ item.setTitle(R.string.disable_wrapping); } editor.toggleWrap(); PreferenceUtils .save(PreferenceUtils.getCodePreferences(this).edit().putBoolean(WRAP, editor.getWrap())); return true; case R.id.m_share: shareFile(); return true; case R.id.m_render_markdown: if (editor.isMarkdown()) { item.setTitle(R.string.render_markdown); editor.toggleMarkdown(); editor.setSource(file, blob); } else { item.setTitle(R.string.show_raw_markdown); editor.toggleMarkdown(); if (renderedMarkdown != null) { editor.setSource(file, renderedMarkdown, false); } else { loadMarkdown(); } } PreferenceUtils.save(PreferenceUtils.getCodePreferences(this).edit().putBoolean(RENDER_MARKDOWN, editor.isMarkdown())); return true; default: return super.onOptionsItemSelected(item); } }