0
holder.iv_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu popupMenu = new PopupMenu(context, holder.iv_delete);
MenuInflater inflater = popupMenu.getMenuInflater();
inflater.inflate(R.menu.menu_Popup, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_alert:
//perform operstion
return true;
case R.id.action_delete:
//perform operstion
return true;
}
return false;
}
});
popupMenu.show();
}
});
}
當我點擊刪除按鈕,其在紅色圓圈彈出菜單需要在該按鈕一側打開,但打開的是上邊的PopupMenu不recycleview正常工作
嘗試'新的PopupMenu(上下文,v);'而不是新的'PopupMenu(context,holder.iv_delete);' –
@EduardoHerzer我試過了,但它不工作。 – skIndia
@skIndia請檢查我的答案。 –