Code example for PopupWindow

Methods: setTouchInterceptor

	 * @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() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					return true; 
				return false; 
Contextual code suggestions in your IDE  Get Codota for Java