当前位置: 首页>>代码示例>>Java>>正文


Java PopupMenu.setOnDismissListener方法代码示例

本文整理汇总了Java中android.support.v7.widget.PopupMenu.setOnDismissListener方法的典型用法代码示例。如果您正苦于以下问题:Java PopupMenu.setOnDismissListener方法的具体用法?Java PopupMenu.setOnDismissListener怎么用?Java PopupMenu.setOnDismissListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.PopupMenu的用法示例。


在下文中一共展示了PopupMenu.setOnDismissListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLongClick

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
void onLongClick() {
  Task currentTask = taskList.get(position);
  CardView cardView = (CardView)itemView;
  float initialElevation = cardView.getCardElevation();
  cardView.setCardElevation(cardView.getCardElevation() * 15);
  PopupMenu menu = new PopupMenu(context, itemView);
  menu.inflate(R.menu.pop_up_menu);
  menu.setOnMenuItemClickListener(item -> {
    switch (item.getItemId()){
      case R.id.edit_task:
        actions.editTask(currentTask, position);
        return true;
      case R.id.delete_task:
        actions.deleteTask(currentTask, position);
    }
    return false;
  });

  menu.setOnDismissListener(popupMenu ->
          cardView.setCardElevation(initialElevation));
  menu.show();
}
 
开发者ID:aumarbello,项目名称:Tasks,代码行数:23,代码来源:TaskViewHolder.java

示例2: showPopMenu

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
private void showPopMenu(int groupPosition, View view) {
  PopupMenu popupMenu = new PopupMenu(this, view);
  getMenuInflater().inflate(R.menu.group_item_menu, popupMenu.getMenu());
  popupMenu.setOnDismissListener(this);
  popupMenu.setOnMenuItemClickListener(this);
  popupMenu.show();
}
 
开发者ID:8enet,项目名称:AppOpsX,代码行数:8,代码来源:PermissionGroupActivity.java

示例3: onOptionsItemSelected

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    if (item.getItemId() == R.id.filter) {
        PopupMenu popup = new PopupMenu(this, findViewById(item.getItemId()));
        final Menu menu = popup.getMenu();

        if (qualities != null && qualities.size() > 0)
            for (int i = 0; i < qualities.size(); i++) {
                Element quality = qualities.get(i);
                menu.add(2, i, 0, quality.getQuality());
            }
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                qualityPosition = menuItem.getItemId();
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(TwitchPlayActivity.this);
                preferences.edit().putInt("player_default_quality", qualityPosition).commit();
                setStreamQuality();
                return true;
            }
        });
        popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
            @Override
            public void onDismiss(PopupMenu popupMenu) {
                toggleHideyBar();
            }
        });
        popup.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:33,代码来源:TwitchPlayActivity.java


注:本文中的android.support.v7.widget.PopupMenu.setOnDismissListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。