android - Popmenu is not aligned on center of listview row -


The code below is used to display PopupMenu, so that it is the center of the

  lv.setOnItemLongClickListener (New OnItemLongClickListener () {Public Boolean onItemLongClick (AdapterView & lt;? & Gt; arg0, see ARG1, last integer status, long ID) {PopupMenu popup = new PopupMenu (context, ARG1); if (Build.VERSION.SDK_INT> = Build.VERSION_CODES.KITKAT) {popup = new PopupMenu (reference, ARG1, Gravity.CENTER);} .mpp file using popup .getMe Enhancing nuInflater () increased (R. Menu.listmenu, popup.getMenu ()); /// Some code returns true;}});  

But the problem popmenu always appears on the left. When I give Gravity. The rifle, Popmenu appears at the top right of the row. What the center display ??

After

you can anchor

 something is going wrong  ShowPopup (viewOfWherePopupmenuShows, popmenuNameList.size ()); Popup menu popmenu = new popup menu (activity. This, v) int size = popmenunlist. Size (); For (int i = 0; i & lt; size; i ++) {popMenu.getMenu () add (popmenuNameList.get (i)) setIcon (R.drawable.logo). } PopMenu.show ();  

...

  Show protected zoom popup menu (see V, integer size) {// example popup menu popup = new popup menu (activity. This, V); // Increase the popup by using XML Popup.Gate MenuInfleter () (R.MenuMenu_Popp_list), popup.temanu ()); For (; I & lt; i = 0 int size; i ++). {Popmenu.getMenu (), add (0, I + 99,0, "text") setcheckable (true) .setChecked (wrong); }}  

Comments