I'm using the ListPopupWindow
:
@NonNull
private ListPopupWindow createListPopupWindow() {
ListPopupWindow listPopupWindow = new ListPopupWindow(mContext);
listPopupWindow.setBackgroundDrawable(mContext.getDrawable(R.drawable.custom_dropdown));
listPopupWindow.setDropDownGravity(Gravity.CENTER);
listPopupWindow.setWidth(ListPopupWindow.WRAP_CONTENT);
listPopupWindow.setHeight(ListPopupWindow.WRAP_CONTENT);
listPopupWindow.setModal(true);
return listPopupWindow;
}
And when I try to call:
listPopupWindow.setAdapter(new DropDownlistAdapter(mContext,
armAwayItems));
View container = (View) listPopupWindow.getListView().getParent();
It always returns NPE
, but this method already exists in the ListPopupWindow
:
Attempt to invoke virtual method 'android.view.ViewParent android.widget.ListView.getParent()' on a null object reference
The same when I try to call
listPopupWindow.getListView().setDividerHeight(1);
and
listPopupWindow.getListView().setDivider(...);
So listPopupWindow.getListView()
always returns NULL.