随缘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 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?