本文整理汇总了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();
}
示例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();
}
示例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);
}