我正在使用 PopupMenu ,我必须修复我单击的按钮下方弹出菜单的位置,但它显示在上面我的按钮下面是我所做的代码。
private final static int ONE = 1;
private final static int TWO = 2;
private final static int THREE = 3;
PopupMenu popupMenu = new PopupMenu(context, convertView.findViewById(R.id.txtOverflowIconList_item_Egov));
popupMenu.getMenu().add(Menu.NONE, ONE, Menu.NONE, "Item 1");
popupMenu.getMenu().add(Menu.NONE, TWO, Menu.NONE, "Item 2");
// popupMenu.getMenu().add(Menu.NONE, THREE, Menu.NONE, "Item 3");
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case ONE:
Toast.makeText(context, "first ", 100).show();
break;
case TWO:
Toast.makeText(context, "Two ", 100).show();
break;
}
return false;
}
});
holder.txtOverflowIcon.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
popupMenu.show();
}
});
下面是我得到的输出:
请帮我。