0
下面是我使用的顯示彈出菜單的代碼,以便它出現在我的列表視圖Popmenu沒有在列表視圖行的中心對齊
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
final int pos, long id) {
PopupMenu popup = new PopupMenu(context, arg1);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popup = new PopupMenu(context, arg1,Gravity.CENTER);
}
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.listmenu, popup.getMenu());
///some code
return true;
}
});
排的中心,但問題是popmenu總是出現在左側。 當我給Gravity.RIGHT時,popmenu確實出現在行的最右側。 中心顯示出了什麼問題?