本文整理汇总了Java中android.view.MenuItem.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setVisible方法的具体用法?Java MenuItem.setVisible怎么用?Java MenuItem.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
if (view.getId() == R.id.post_image_edit_layout) {
PopupMenu popupMenu = new PopupMenu(this, mPostImageLayoutManager.getRootLayout());
popupMenu.inflate(R.menu.insert_image);
if (TextUtils.isEmpty(mPost.getFeatureImage())) {
MenuItem removeImageItem = popupMenu.getMenu().findItem(R.id.action_image_remove);
removeImageItem.setVisible(false);
}
popupMenu.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.action_insert_image_url) {
mPostEditFragment.onInsertImageUrlClicked(getInsertImageDoneAction());
} else if (item.getItemId() == R.id.action_insert_image_upload) {
mPostEditFragment.onInsertImageUploadClicked(getInsertImageDoneAction());
} else if (item.getItemId() == R.id.action_image_remove) {
getInsertImageDoneAction().call("");
}
return true;
});
popupMenu.show();
}
}
示例2: onCreateContextMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.volume_browser_context, menu);
// if (!this.mEDVolume.getFileProvider().allowRemoteCopy()){
// MenuItem MenuItem =(MenuItem )menu.findItem(R.id.volume_browser_menu_copy);
// MenuItem.setVisible(false);
// }
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) menuInfo;
int pos = info.position;
EDFileChooserItem selectedFile = mCurFileList.get(pos-1);
MenuItem MenuItem =(MenuItem )menu.findItem(R.id.volume_browser_generage_thumbnail);
if (selectedFile != null && (MimeManagement.isImage(selectedFile.getName()) || MimeManagement.isVideo(selectedFile.getName()))){
MenuItem.setVisible(true);
} else {
MenuItem.setVisible(false);
}
}
示例3: onPrepareOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
/*
app share and rate group
hide on AurPackageDetailsFragment
*/
MenuItem menuItem = menu.findItem(R.id.menu_main_app_group);
Fragment fragmentByTag = fragmentManager.findFragmentByTag(AUR_PACKAGE_DETAILS_FRAGMENT_TAG);
menuItem.setVisible(fragmentByTag == null);
// night mode
switch (AppCompatDelegate.getDefaultNightMode()) {
case AppCompatDelegate.MODE_NIGHT_AUTO:
menu.findItem(R.id.menu_main_action_night_mode_auto).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
menu.findItem(R.id.menu_main_action_night_mode_night).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_NO:
menu.findItem(R.id.menu_main_action_night_mode_day).setChecked(true);
break;
}
return true;
}
示例4: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_item_prepare) {
Toast.makeText(
this,
"Your file is being prepared",
Toast.LENGTH_SHORT)
.show();
prepareItemForSharing();
item.setVisible(false);
// share icon will be visible after preparation is done
} else {
Timber.d("menuItem:"+item.toString());
}
return super.onOptionsItemSelected(item);
}
示例5: onCreateContextMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, view, menuInfo);
MenuInflater inflater = getMenuInflater();
if (Util.isOffline(this)) inflater.inflate(R.menu.select_playlist_context_offline, menu);
else inflater.inflate(R.menu.select_playlist_context, menu);
MenuItem downloadMenuItem = menu.findItem(R.id.album_menu_download);
if (downloadMenuItem != null)
{
downloadMenuItem.setVisible(!Util.isOffline(this));
}
}
示例6: updateModeTitle
import android.view.MenuItem; //导入方法依赖的package包/类
public void updateModeTitle()
{
android.support.v7.view.ActionMode mode = ((MainActivity) activity).getActionMode();
if (mode != null)
{
final int selected = formulas.getSelectedEquations().size();
final int total = formulas.getEquationsNumber();
if (selected == 0)
{
mode.setTitle("");
}
else
{
mode.setTitle(String.valueOf(selected) + "/" + String.valueOf(total));
}
Menu m = mode.getMenu();
if (m != null)
{
MenuItem mi = m.findItem(R.id.context_menu_expand);
if (mi != null)
{
mi.setVisible(total > selected);
}
}
}
}
示例7: onPrepareOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// menu items
MenuItem imSetAsWorkingFolder = menu.findItem(R.id.im_set_as_working_folder);
MenuItem imIsWorkingFolder = menu.findItem(R.id.im_is_working_folder);
MenuItem imSelectFolder = menu.findItem(R.id.im_select_folder);
if (imSetAsWorkingFolder != null) {
// set the imSetAsWorkingFolder visible only if the two folder dont concide
imSetAsWorkingFolder.setVisible(!currentFolder.equals(PreferenceHelper.getWorkingFolder(SelectFileActivity.this)));
}
if (imIsWorkingFolder != null) {
// set visible is the other is invisible
imIsWorkingFolder.setVisible(!imSetAsWorkingFolder.isVisible());
}
if (imSelectFolder != null) {
imSelectFolder.setVisible(!wantAFile);
}
return super.onPrepareOptionsMenu(menu);
}
示例8: onPrepareActionMode
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
final int checkedCount = mChoiceMode.getCheckedItemCount();
// Show / hide menu items or menu groups based on number of checked items
final MenuItem item = menu.findItem(R.id.action_delete);
item.setVisible(checkedCount > 0);
// Update action mode title
if (checkedCount > 0) {
final Resources resources = getResources();
mode.setTitle(resources.getQuantityString(R.plurals.action_mode_x_items_selected,
checkedCount, checkedCount));
} else {
mode.setTitle(R.string.action_mode_no_items_selected);
}
return true;
}
示例9: onCreateOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_eventdetail_menu, menu);
MenuItem feedbackMenuItem = menu.findItem(R.id.feedback_menu);
if(!URLUtil.isValidUrl(event.getFeedback()))
feedbackMenuItem.setVisible(false);
return true;
}
示例10: onCreateOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_disciplinas, menu);
MenuItem item = menu.findItem(R.id.action_refresh);
if (DataSource.getInstance(this).containDisciplinasWeb())
item.setVisible(true);
return true;
}
示例11: onPrepareOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (!isSelf) {
MenuItem follow = menu.findItem(R.id.action_follow);
follow.setTitle(getFollowAction());
follow.setVisible(followState != FollowState.REQUESTED);
MenuItem block = menu.findItem(R.id.action_block);
String title;
if (blocking) {
title = getString(R.string.action_unblock);
} else {
title = getString(R.string.action_block);
}
block.setTitle(title);
MenuItem mute = menu.findItem(R.id.action_mute);
if (muting) {
title = getString(R.string.action_unmute);
} else {
title = getString(R.string.action_mute);
}
mute.setTitle(title);
} else {
// It shouldn't be possible to block or follow yourself.
menu.removeItem(R.id.action_follow);
menu.removeItem(R.id.action_block);
menu.removeItem(R.id.action_mute);
}
return super.onPrepareOptionsMenu(menu);
}
示例12: setupShareBtn
import android.view.MenuItem; //导入方法依赖的package包/类
protected void setupShareBtn() {
if (this.mMenu != null && this.mMenu.size() > 0) {
MenuItem item = this.mMenu.findItem(R.id.action_share);
if (item != null) {
boolean z = !TextUtils.isEmpty(this.mUrl) && this.mUrl.contains("share=true");
item.setVisible(z);
}
}
}
示例13: onCreateOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_detalhe, menu);
MenuItem item = menu.findItem(R.id.action_delete);
if (idAnotacao == null)
item.setVisible(false);
return true;
}
示例14: updateHeartButton
import android.view.MenuItem; //导入方法依赖的package包/类
private void updateHeartButton(boolean isLike) {
if (null != mPhotoMenu && UserUtils.isAuthorized()) {
MenuItem item = mPhotoMenu.getItem(1);
item.setVisible(true);
item.setIcon(isLike ? R.drawable.ic_favorite_red_24dp : R.drawable.ic_favorite_border_24dp);
View likeMenuView = mToolbar.findViewById(R.id.action_like);
if (null == likeMenuView) return;
SpringyAnimator springHelper = new SpringyAnimator(SpringAnimationType.SCALEXY, 100, 4, 0, 1);
springHelper.startSpring(likeMenuView);
}
}
示例15: onPrepareOptionsMenu
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.open_poll).setVisible(mTopicPollAvailable);
MenuItem gotoSource = menu.findItem(R.id.to_commented);
gotoSource.setVisible(mGotoSourceAvailable);
if (mGotoSourceAvailable) {
gotoSource.setTitle(mGotoSourceText);
}
}