傳統的PopupWindow在獲取view的時候是使用
- Java代碼
- final View view = LayoutInflater.from(this).inflate(R.layout.popuwindow, null);
- pop = new PopupWindow(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
樣,當彈出第二個PopupWindow的時候,就會報錯,原因是當前的context不是一個Activity。所以改成如下的代碼即可:
- Java代碼
- LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);