我想知道如何一旦用戶點擊外面關閉POP_UP窗口,我在PopupWindow - Dismiss when clicked outside但沒有任何運氣一看,我試圖代碼:如何在外部點擊時關閉彈出窗口?
pw.setBackgroundDrawable(null);
pw.setOutsideTouchable(true);
pw.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_OUTSIDE)
{
pw.dismiss();
return true;
}
return false;
}
});
我想你忘了在使用'onTouch(....)'方法之前添加'@ Override'。試試這種方法'@Override public boolean onTouch(View v,MotionEvent event){........}' –