0

I have a MapFragment in which, upon clicking a marker I'm showing a PopupWindow. I can't seem to get it to receive TouchEvents though.

Here's what I've got atm:

mPopupWindow.getContentView().setOnClickListener(new OnClickListener()
{

    @Override
    public void onClick(View v)
    {
        Log.d("msg", "PopupWindow onClick");

    }

});

when invoking the particular PopupWindow:

mPopupWindow.setTouchable(true);
mPopupWindow.showAtLocation(mMapLinearLayout, x, y) //root is a subclass of LinearLayout

Haven't seen a message from the listener yet.

Edit: for your information: inside my window there are images that are loaded asynchronously

mewa
  • 1,532
  • 1
  • 12
  • 20
  • please refer this http://stackoverflow.com/questions/15876390/android-maps-v2-click-on-popup – George Thomas Jun 17 '14 at 14:01
  • I think I can't use the standard InfoWindow, since afaik it renders it as an image onto the map and in my window I have images that are being loaded asynchronously, meaning that only their placeholders would get rendered. On a side note: Should I load them on the UI thread instead maybe? They're downloaded, so it could become quite a problem... – mewa Jun 17 '14 at 14:11

1 Answers1

0

The PopupWindow has a pretty unintuitive bug concerning TouchEvents. Found solution here.

Namely: PopupWindow will not capture any events, unless it has a background

mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); // you have to set background
mPopupWindow.setTouchInterceptor(new OnTouchListener()
{
    @Override
    public boolean onTouch(View v, MotionEvent ev)
    {
        Log.d("msg", "PopupWindow onTouch");
        }
        return false;
    }
});
mewa
  • 1,532
  • 1
  • 12
  • 20