android.support.v7.widget.PopupMenu.dismiss()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中android.support.v7.widget.PopupMenu.dismiss()方法的一些代码示例,展示了PopupMenu.dismiss()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PopupMenu.dismiss()方法的具体详情如下:
包路径:android.support.v7.widget.PopupMenu
类名称:PopupMenu
方法名:dismiss

PopupMenu.dismiss介绍

暂无

代码示例

代码示例来源:origin: willowtreeapps/Hyperion-Android

@Override
public void onMenuStateChanged(@NonNull MenuState menuState) {
  if (menuState == MenuState.CLOSING && popupMenu != null) {
    popupMenu.dismiss();
  }
}

代码示例来源:origin: willowtreeapps/Hyperion-Android

private void showMenu(View anchor) {
  final Context context = anchor.getContext();
  if (popupMenu != null) {
    popupMenu.dismiss();
  }
  popupMenu = new PopupMenu(context, anchor);
  popupMenu.inflate(R.menu.hgc_menu_options);
  final Menu menu = popupMenu.getMenu();
  final MenuItem areHapticsEnabledItem = menu.findItem(R.id.menu_item_use_haptics);
  areHapticsEnabledItem.setChecked(detector.areHapticsEnabled());
  areHapticsEnabledItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      boolean areHapticsEnabled = !item.isChecked();
      item.setChecked(areHapticsEnabled);
      detector.setHapticsEnabled(areHapticsEnabled);
      return true;
    }
  });
  popupMenu.show();
}

代码示例来源:origin: milosmns/silly-android

/**
 * Tries to dismiss the given {@link PopupMenu}.
 *
 * @param menu Which menu to dismiss
 * @return {@code True} if the given menu is not {@code null} and dismiss was invoked; {@code false} otherwise
 */
public static boolean dismiss(@Nullable final PopupMenu menu) {
  if (menu != null) {
    menu.dismiss();
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: yuger/TVLive

@Override
  public boolean onMenuItemClick(MenuItem item) {
    int itemId = item.getItemId();
    if (itemId == R.id.float_window) {
      mediaPlayer.startFloatWindow();
    } else if (itemId == R.id.scale_default) {
      mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_DEFAULT);
    } else if (itemId == R.id.scale_original) {
      mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_ORIGINAL);
    } else if (itemId == R.id.scale_match) {
      mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_MATCH_PARENT);
    } else if (itemId == R.id.scale_16_9) {
      mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_16_9);
    } else if (itemId == R.id.scale_4_3) {
      mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_4_3);
    }
    popupMenu.dismiss();
    return false;
  }
});

相关文章