ListPopupWindow not obeying WRAP_CONTENT width spec

前端 未结 9 1552
执念已碎
执念已碎 2021-02-02 07:12

I\'m trying to use ListPopupWindow to show a list of strings via an ArrayAdapter (eventually this will be a more complex custom adapter). Code is below. As shown in

9条回答
  •  旧时难觅i
    2021-02-02 07:38

    I think the best thing to use is the PopupMenu . example:

    final PopupMenu popupMenu = new PopupMenu(mActivity, v);
    popupMenu.getMenu().add("test");
    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    
        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            return true;
        }
    });
    popupMenu.show();
    

提交回复
热议问题