本文整理匯總了Java中android.view.MenuItem.setTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setTitle方法的具體用法?Java MenuItem.setTitle怎麽用?Java MenuItem.setTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setTitle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_main, menu);
if (isPlaylistPage()) {
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
}
Fragment currentFragment = getCurrentFragment();
if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
if (Util.isLandscape(getResources())) {
gridSizeItem.setTitle(R.string.action_grid_size_land);
}
setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());
menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
} else {
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
menu.removeItem(R.id.action_grid_size);
menu.removeItem(R.id.action_colored_footers);
}
colorToolbar();
}
示例2: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
if (item == mItemFace50)
setMinFaceSize(0.5f);
else if (item == mItemFace40)
setMinFaceSize(0.4f);
else if (item == mItemFace30)
setMinFaceSize(0.3f);
else if (item == mItemFace20)
setMinFaceSize(0.2f);
else if (item == mItemType) {
int tmpDetectorType = (mDetectorType + 1) % mDetectorName.length;
item.setTitle(mDetectorName[tmpDetectorType]);
setDetectorType(tmpDetectorType);
}
return true;
}
示例3: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (mPresenter.getIssue() != null) {
getMenuInflater().inflate(R.menu.menu_issue_detail, menu);
boolean isCanToggle = AppData.INSTANCE.getLoggedUser().getLogin()
.equals(mPresenter.getIssue().getUser().getLogin()) ||
AppData.INSTANCE.getLoggedUser().getLogin()
.equals(mPresenter.getIssue().getRepoAuthorName());
boolean isOpen = mPresenter.getIssue().getState().equals(Issue.IssueState.open);
if (isCanToggle) {
MenuItem item = menu.findItem(R.id.action_issue_toggle);
item.setTitle(isOpen ? R.string.close : R.string.reopen);
} else {
menu.removeItem(R.id.action_issue_toggle);
}
}
return true;
}
示例4: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu_main, menu);
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
switch (menuItem.getItemId()) {
case R.id.action_share:
menuItem.setTitle(StringsManager.getString("menu_share_app"));
break;
case R.id.action_language:
menuItem.setTitle(StringsManager.getString("menu_language"));
break;
}
}
if (mFragment instanceof ShareFragment) {
menu.findItem(R.id.action_share).setVisible(true);
menu.findItem(R.id.action_language).setVisible(false);
} else {
menu.findItem(R.id.action_share).setVisible(false);
menu.findItem(R.id.action_language).setVisible(true);
}
return super.onCreateOptionsMenu(menu);
}
示例5: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.action_music:
MusicDialog dialog = MusicDialog.newInstance();
dialog.show(getSupportFragmentManager(), "MusicDialogFragment");
return true;
case R.id.action_preview:
if (mTextLoaded) {
if (!mPreviewMode) {
showPreviewMode();
item.setIcon(R.drawable.ic_edit);
item.setTitle(R.string.action_edit);
} else {
showEditMode();
item.setIcon(R.drawable.ic_preview);
item.setTitle(R.string.action_preview);
}
} else {
Toast.makeText(this, R.string.preview_error_msg, Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_save:
saveDocument(new Callbacks.FinishCallback<Void>() {
@Override
public void onFinish(Void result) {
Toast.makeText(EditDocActivity.this, R.string.save_success_msg, Toast.LENGTH_LONG).show();
}
});
return true;
}
return super.onOptionsItemSelected(item);
}
示例6: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
if (getString(R.string.g6).equals(item.getTitle())) {
item.setTitle(R.string.g7);
this.mAdapter.setEdit(true);
this.rippleLayout.setVisibility(8);
this.viewOperate.setVisibility(0);
this.viewOperate.startAnimation(AnimationUtils.loadAnimation(this, R.anim.o));
return true;
}
item.setTitle(R.string.g6);
this.mAdapter.setEdit(false);
this.viewOperate.animate().alphaBy(1.0f).alpha(0.0f).setDuration(300).setListener
(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
CollectionActivity.this.viewOperate.setVisibility(8);
CollectionActivity.this.rippleLayout.setVisibility(0);
CollectionActivity.this.viewOperate.setAlpha(1.0f);
}
}).start();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例7: swapMenuItemTitle
import android.view.MenuItem; //導入方法依賴的package包/類
public void swapMenuItemTitle(MenuItem item) {
if (item.getTitle() == null) {
//IMPORTANT this prevents crashes when onOptionsItemSelected() is called from
//the user pressing the back button or the info dialog.
//if this is removed the other checks throw nullpointers, so keep it here.
}
else if(item.getTitle().toString().contains("Ascending")){
item.setTitle(item.getTitle().toString().replace("Ascending", "Descending"));
}
else if (item.getTitle().toString().contains("Descending")){//the filter items will contain neither.
item.setTitle(item.getTitle().toString().replace("Descending", "Ascending"));
}
}
示例8: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_crime_list, menu);
MenuItem subtitleItem = menu.findItem(R.id.show_subtitle);
if (mSubtitleVisible) {
subtitleItem.setTitle(R.string.hide_subtitle);
} else {
subtitleItem.setTitle(R.string.show_subtitle);
}
}
示例9: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_crime_list, menu);
MenuItem subtitle = menu.findItem(R.id.show_subtitle);
if (mSubtitleVisible) {
subtitle.setTitle(R.string.hide_subtitle);
} else {
subtitle.setTitle(R.string.show_subtitle);
}
}
示例10: changeEditMode
import android.view.MenuItem; //導入方法依賴的package包/類
private void changeEditMode(MenuItem item) {
if (this.tvDelete.getVisibility() == 0) {
this.mAdapter.setShowSelect(false);
this.tvDelete.setVisibility(8);
this.selectLine.setVisibility(4);
item.setTitle(getString(R.string.jk));
} else if (this.tvDelete.getVisibility() == 8) {
this.mAdapter.setShowSelect(true);
this.tvDelete.setVisibility(0);
this.selectLine.setVisibility(0);
item.setTitle(getString(R.string.jl));
}
}
示例11: onPrepareOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@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);
}
示例12: onMenuItemClick
import android.view.MenuItem; //導入方法依賴的package包/類
@Override public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.layoutType) {
mHorizontal = !mHorizontal;
setupAdapter();
item.setTitle(mHorizontal ? "Vertical" : "Horizontal");
}
return false;
}
示例13: updateDrawerUserInformation
import android.view.MenuItem; //導入方法依賴的package包/類
/**
* Update user information in drawer
*/
private void updateDrawerUserInformation() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_drawer);
Menu menu = navigationView.getMenu();
MenuItem userName = menu.findItem(R.id.nav_user_name);
userName.setTitle(SharedPrefClass.getFirstName(this) + " " + SharedPrefClass.getLastName(this));
MenuItem userEmail = menu.findItem(R.id.nav_user_email);
userEmail.setTitle(SharedPrefClass.getEmail(this));
MenuItem userPoints = menu.findItem(R.id.nav_user_points);
userPoints.setTitle(Integer.toString(SharedPrefClass.getPoints(this)) + " points");
}
示例14: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.p, menu);
MenuItem item = menu.findItem(R.id.action_record);
item.setTitle("");
item.setIcon(0);
return true;
}
示例15: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (menu != null) {
MenuItem item = menu.findItem(R.id.action_bar_save);
if (updateMode && item != null) {
item.setTitle(R.string.update_hint);
}
}
}