【问题标题】:During the Loading several images in ImageView get Out of Memory exception [duplicate]在 ImageView 中加载多个图像期间出现内存不足异常 [重复]
【发布时间】:2014-03-03 04:00:26
【问题描述】:

您好,我已经创建了一个应用程序。

在应用程序中,我从 URL 加载了几个图像。但是在加载图像的过程中,我得到了Out Of Memory 异常。

给我解决这个问题的方法。

【问题讨论】:

标签: android imageview


【解决方案1】:

嗯,现在从互联网加载图像的时间有很多解决方案。你也可以使用这个库“Android-Query”https://code.google.com/p/android-query/wiki/ImageLoading。它会给你所有需要的活动。确定你想做什么?并阅读图书馆维基页面。并解决图片加载限制。

这是我的代码:-

@Override
public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.row, null);
        }

         ImageView imageview = (ImageView) v.findViewById(R.id.icon);
               AQuery aq = new AQuery(convertView);

               String imageUrl = "http://www.vikispot.com/z/images/vikispot/android-w.png";

              aq.id(imageview).progress(this).image(imageUrl, true, true, 0, 0, new BitmapAjaxCallback(){

                       @Override
                       public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status){

                           iv.setImageBitmap(bm);


                       }

               });

        }
        return v;
}

应该可以解决你的延迟加载

【讨论】:

    猜你喜欢
    • 2011-06-18
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    • 1970-01-01
    相关资源
    最近更新 更多