Code example for PopupWindow

Methods: setTouchInterceptor

0
     * @param context 
     *            Context 
     */ 
    public PopupWindows(final Context context) {
        mContext = context;
        mWindow = new PopupWindow(context);
 
        mWindow.setTouchInterceptor(new OnTouchListener() {
            @Override 
            public boolean onTouch(final View v, final MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    mWindow.dismiss();
 
                    return true; 
                } 
 
                return false; 
            } 
        }); 
 
        mWindowManager = (WindowManager) context