我有一个BroadcastReceiver用于来电和接听来电我想要给视图充气。
但是当我在调用状态为IDLE时尝试删除视图时,应用程序崩溃: java.lang.IllegalArgumentException:view不能为null
我的代码:
showview();
在onPostExecute中我调用
public void showview(){
params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CENTER | Gravity.CENTER;
params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
wm = (WindowManager) mContext.getSystemService(mContext.WINDOW_SERVICE);
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.child, null);
txtIncomingnumber = (TextView) view.findViewById(R.id.txtviewoncall);
txtIncomingnumber.setText("TEST");
wm.addView(view, params);
}
public void removeview(){
wm.removeView(view);
}
这是我的方法:
.gallery-item {
display: none;
}