随缘56 2019-12-09 15:50 采纳率: 0%
浏览 1940
已结题

android 中使用Glide加载图片无效,该怎么解决?

android 中使用.Glide加载图片无效,该怎么解决?

public View getView(int position, View view, ViewGroup parent) {
            if (view==null) {
                view = LayoutInflater.from(getContext()).inflate(resource, parent, false);
            }
            News news=getItem(position);
            ImageView imageView=view.findViewById(R.id.lv_image);
            TextView name=view.findViewById(R.id.lv_title);
            TextView from=view.findViewById(R.id.lv_from);
            TextView time=view.findViewById(R.id.lv_time);
            TextView read_num=view.findViewById(R.id.lv_read_num);
            String s="http:"+news.getPic();
            Log.v("ssss",s);
           Glide.with(view.getContext()).load(s).into(imageView);
            name.setText(news.getName());
            from.setText(news.getFrom());
            time.setText(news.getTime());
            read_num.setText(news.getRead_num());
            return view;

    }

报错

class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There were 2 causes:
    java.io.IOException(Cleartext HTTP traffic to image2.thepaper.cn not permitted)
    java.io.FileNotFoundException(No content provider: http://image2.thepaper.cn/image/40/838/183.jpg)


大佬们,该怎么解决

  • 写回答

5条回答 默认 最新

  • threenewbee 2019-12-09 16:02
    关注

    Picasso.with(view.getContext()).load(s).into(imageView);
    这里load只能是本地路径,不能是url
    你得用httpclient先下载文件到本地,再用本地的文件名去load

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog