java.lang.IllegalArgumentException: You must pass in a non null View

 Caused by: java.lang.IllegalArgumentException: You must pass in a non null View

不合法的异常,View为空

找到报错的地方

Glide.with(getActivity())
        .load(nb.getImg1())
        .error(R.mipmap.ic_launcher)
        .into(iv);

通过Glide加载图片,into(iv)是ImageView类型的图片,报错说明传来的 iv 为空,又找到 View 类型的方法

public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle saveInstanceState){
        iv=new ImageView(getActivity());
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
        iv.setLayoutParams(lp);   //设置图片宽和高的参数
        iv.setScaleType(ImageView.ScaleType.FIT_XY);   //把图片填满整个控件
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (nb==null){
                    Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
                    intent.putExtra("newsBean",nb);
                    getActivity().startActivity(intent);
                }
            }
        });
        return iv;
    }

结果检查是onCreateView()方法由于手误写成了OnCreateView().才报的做,改完就ok了。

你可能感兴趣的:(java.lang.IllegalArgumentException: You must pass in a non null View)