Code example for PopupWindow

Methods: setTouchInterceptor

0
	 * @param anchor 
	 *            the view that the QuickAction will be displaying 'from' 
	 */ 
	public CustomPopupWindow(View anchor) {
		this.anchor = anchor;
		this.window = new PopupWindow(anchor.getContext());
 
		// when a touch even happens outside of the window 
		// make the window go away 
		window.setTouchInterceptor(new OnTouchListener() {
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					CustomPopupWindow.this.window.dismiss();
					 
					return true; 
				} 
				 
				return false; 
			} 
		});