A possible solution is as follows:
- A grandparent of the anchor view is the view returned by
Adapter.getView()
. Upon showing aPopupWindow
as drop-down, store a flag in the grandparent's tag. Also store a reference to this gandparent, and the selected item id. - In
Adapter.getView()
, when the requested item id equals the selected item id, usePopupWindow.update()
to attach the popup to the new view. Remove the tag from the old grandparent and update the grandparent reference. - In
Adapter.getView()
if you get aconvertView
which has the flagged tag, and the requested item id differs from the selected item id, usePopupWindow.update()
to un-attach the popup from the grandparent. Set the grandparent tonull
.
This is a bit complicated so I haven't tried it yet, but it should work and I'm writing it here in case someone's interested.