本文整理了Java中android.view.MenuItem.setTitle()
方法的一些代码示例,展示了MenuItem.setTitle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setTitle()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:setTitle
暂无
代码示例来源:origin: stackoverflow.com
public class YourActivity extends Activity {
private Menu menu;
private String inBedMenuTitle = "Set to 'In bed'";
private String outOfBedMenuTitle = "Set to 'Out of bed'";
private boolean inBed = false;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
// Create your menu...
this.menu = menu;
return true;
}
private void updateMenuTitles() {
MenuItem bedMenuItem = menu.findItem(R.id.bedSwitch);
if (inBed) {
bedMenuItem.setTitle(outOfBedMenuTitle);
} else {
bedMenuItem.setTitle(inBedMenuTitle);
}
}
}
代码示例来源:origin: pockethub/PocketHub
private void updateWrapItem() {
if (wrapItem != null) {
if (codePrefs.getBoolean(WRAP, false)) {
wrapItem.setTitle(R.string.disable_wrapping);
} else {
wrapItem.setTitle(R.string.enable_wrapping);
}
}
}
代码示例来源:origin: naman14/Timber
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
if (showAuto) {
menu.findItem(R.id.action_view_auto_playlists).setTitle("Hide auto playlists");
} else menu.findItem(R.id.action_view_auto_playlists).setTitle("Show auto playlists");
}
代码示例来源:origin: nickbutcher/plaid
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
final MenuItem designerNewsLogin = menu.findItem(R.id.menu_designer_news_login);
if (designerNewsLogin != null) {
designerNewsLogin.setTitle(loginRepository.isLoggedIn() ?
R.string.designer_news_log_out : R.string.designer_news_login);
}
return true;
}
代码示例来源:origin: naman14/Timber
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (action.equals(Constants.NAVIGATE_PLAYLIST_USERCREATED)) {
menu.findItem(R.id.action_delete_playlist).setVisible(true);
menu.findItem(R.id.action_clear_auto_playlist).setVisible(false);
} else {
menu.findItem(R.id.action_delete_playlist).setVisible(false);
menu.findItem(R.id.action_clear_auto_playlist).setTitle("Clear " + playlistname.getText().toString());
}
return super.onPrepareOptionsMenu(menu);
}
代码示例来源:origin: umano/AndroidSlidingUpPanel
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.demo, menu);
MenuItem item = menu.findItem(R.id.action_toggle);
if (mLayout != null) {
if (mLayout.getPanelState() == PanelState.HIDDEN) {
item.setTitle(R.string.action_show);
} else {
item.setTitle(R.string.action_hide);
}
}
return true;
}
代码示例来源:origin: smuyyh/BookReader
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_sub_category, menu);
menuItem = menu.findItem(R.id.menu_major);
if (!TextUtils.isEmpty(cate)) {
menuItem.setTitle(cate);
}
return true;
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void updateBookmarkButtons() {
if (playlistBookmarkButton == null || activity == null) return;
final int iconAttr = playlistEntity == null ?
R.attr.ic_playlist_add : R.attr.ic_playlist_check;
final int titleRes = playlistEntity == null ?
R.string.bookmark_playlist : R.string.unbookmark_playlist;
playlistBookmarkButton.setIcon(ThemeHelper.resolveResourceIdFromAttr(activity, iconAttr));
playlistBookmarkButton.setTitle(titleRes);
}
}
代码示例来源:origin: stackoverflow.com
MenuItem mi = m.getItem(m.size()-1);
mi.setTitle(mi.getTitle());
代码示例来源:origin: wangdan/AisenWeiBo
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem item = menu.findItem(R.id.menu_confirm);
item.setVisible(selectedFile.size() > 0);
item.setTitle(String.format("完成(%d/%d)", selectedFile.size(), maxSize));
}
代码示例来源:origin: hidroh/materialistic
@Override
public PopupMenu setMenuItemTitle(@IdRes int itemResId, @StringRes int title) {
mSupportPopupMenu.getMenu().findItem(itemResId).setTitle(title);
return this;
}
代码示例来源:origin: stackoverflow.com
private void applyFontToMenuItem(MenuItem mi) {
Typeface font = Typeface.createFromAsset(getAssets(), "ds_digi_b.TTF");
SpannableString mNewTitle = new SpannableString(mi.getTitle());
mNewTitle.setSpan(new CustomTypefaceSpan("" , font), 0 , mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
mi.setTitle(mNewTitle);
}
代码示例来源:origin: pockethub/PocketHub
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem followItem = menu.findItem(R.id.m_star);
followItem.setVisible(starredStatusChecked);
followItem.setTitle(isStarred ? R.string.unstar : R.string.star);
MenuItem parentRepo = menu.findItem(R.id.m_parent_repo);
if(repository != null && repository.isFork() != null)
parentRepo.setVisible(repository.isFork());
return super.onPrepareOptionsMenu(menu);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.your_menu, menu);
int positionOfMenuItem = 0; // or whatever...
MenuItem item = menu.getItem(positionOfMenuItem);
SpannableString s = new SpannableString("My red MenuItem");
s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
item.setTitle(s);
}
代码示例来源:origin: pockethub/PocketHub
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem followItem = menu.findItem(R.id.m_follow);
boolean isCurrentUser = user.login().equals(AccountUtils.getLogin(this));
followItem.setVisible(followingStatusChecked && !isCurrentUser);
followItem.setTitle(isFollowing ? R.string.unfollow : R.string.follow);
return super.onPrepareOptionsMenu(menu);
}
代码示例来源:origin: smuyyh/BookReader
@Override
public void initToolBar() {
cate = getIntent().getStringExtra(INTENT_CATE_NAME);
if (menuItem != null) {
menuItem.setTitle(cate);
}
gender = getIntent().getStringExtra(INTENT_GENDER);
mCommonToolbar.setTitle(cate);
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
代码示例来源:origin: pockethub/PocketHub
@Override
public void onPrepareOptionsMenu(Menu menu) {
boolean owner = isOwner();
if (!owner) {
menu.removeItem(R.id.m_delete);
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);
}
}
代码示例来源:origin: hidroh/materialistic
@Override
protected void prepareOptionsMenu(Menu menu) {
MenuItem menuReadability = menu.findItem(R.id.menu_readability);
menuReadability.setVisible(modeToggleEnabled());
mMenuTintDelegate.setIcon(menuReadability, mReadability ?
R.drawable.ic_web_black_24dp : R.drawable.ic_chrome_reader_mode_black_24dp);
menuReadability.setTitle(mReadability ? R.string.article : R.string.readability);
menu.findItem(R.id.menu_font_options).setVisible(fontEnabled());
}
代码示例来源:origin: pockethub/PocketHub
@SuppressLint("CommitPrefEdits")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.m_wrap:
if (editor.getWrap()) {
item.setTitle(R.string.enable_wrapping);
editor.setWrap(false);
} else {
item.setTitle(R.string.disable_wrapping);
editor.setWrap(true);
}
PreferenceUtils.save(codePrefs.edit().putBoolean(WRAP,
editor.getWrap()));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: hidroh/materialistic
@SuppressLint("NewApi")
@Override
public PopupMenu setMenuItemTitle(@IdRes int itemResId, @StringRes int title) {
popupMenu.getMenu().findItem(itemResId).setTitle(title);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!