java.lang.IllegalArgumentException:view不能为null

时间:2015-05-30 16:03:07

标签: android imageview fragment

我希望始终将ImageView显示在最前面。此ImageView位于Fragment
但是,我收到了一条错误消息。

java.lang.IllegalArgumentException: view must not be null


这是我的代码。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    View rootView = inflater.inflate(R.layout.fragment_mapview, container, false);
    mImageFloor = (ImageView) rootView.findViewById(R.id.img_floor);


    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, 
            PixelFormat.TRANSLUCENT);                                                          

    WindowManager wm = (WindowManager) getActivity().getSystemService(mContext.WINDOW_SERVICE);
    wm.addView(mImageFloor, params);  // *This line has an error


我做错了吗?

0 个答案:

没有答案