Possible Duplicate:
How to dismiss the dialog with click on outside of the dialog?
How can I click outside of a popup to dismiss it?
Here is my code:
cell.setOnClickListener(new OnClickListener(){
/*This code is in a separate class so I needed to use ctx as context
*and the string "layout_inflater" because it was not recognizing
*LAYOUT_INFLATER_SERVICE*/
@Override
public void onClick(View arg0) {LayoutInflater layoutInflater =
(LayoutInflater)ctx.getSystemService("layout_inflater");
View popupView = layoutInflater.inflate(R.layout.popup_window, null);
final PopupWindow popupWindow = new PopupWindow(popupView,
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
popupWindow.showAtLocation(newParentLayout, Gravity.CENTER, 0, 0);
}
I've also tried adding all of this but no results.
popupWindow.setTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
Drawable bg = ctx.getResources().getDrawable(R.drawable.popup_bg);
popupWindow.setBackgroundDrawable(bg);
I'm out of ideas. Any help?
Edit to add: the main layout is a ViewPager/PagerAdapter if that would affect anything?