When I click on a thumbnail, a popup window opens. I want to dismiss it in the onTouch method but the problem is that the onTouch method is not getting called.So How can i get it run? How can I dismiss the popup window?
my code is:
public void onItemImageClicked(View view)
{
LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.popup,null);
ImageView fullSizeImg = (ImageView) layout.findViewById(R.id.fullSizeImage);
fullSizeImg.setImageBitmap(bitmap);
fullSizeImg.setFocusable(false);
Display display = getWindowManager().getDefaultDisplay();
int deviceWidth = display.getWidth()-40;
int deviceHeight = display.getHeight()-70;
popupWindow = new PopupWindow(layout, deviceWidth, deviceHeight, true);
// display the popup in the center
popupWindow.showAtLocation(layout, Gravity.CENTER, 0, 0);
popupWindow.getMaxAvailableHeight(new View(this));
popupWindow.setFocusable(true);
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
popupWindow.dismiss();
return false;
}
});
popupWindow.setTouchable(true);
}
Try this
And
onClickEvent