我彈出窗口功能有一個小問題。我想在用戶點擊窗口外部時關閉它。我已經閱讀了很多關於stackoverflow的腳本,但是沒有一篇文章對我有幫助。我試過的是,我試圖popupwindow.setBackgroundDrawable(null);這不適合我。Android - 當點擊視圖外部時關閉popUpWindow
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popupmenu_layout, (ViewGroup) findViewById(R.id.popuplinearlayout));
pw = new PopupWindow(layout, 300, 300, true);
pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
pw.setBackgroundDrawable(null);
pw.setOutsideTouchable(true);
//Todo remove popup window when outside is touched...
如果你知道一個很好的文章有什麼可以幫助我,我將不勝感激it.It是更多鈔票這個功能是不是在模擬器工作?我只有模擬器現在。的
pw.setBackgroundDrawable(null);
(是Android 4.4.2)
你嘗試我張貼的答案?接受它,如果它適合你 – 2014-09-12 17:06:14