我有一个在列表视图中显示的ParseObjects数组。三个文本视图被加载到我的自定义单元格中,然后ParseFile中的一个图像也应该被加载。我的代码让第一个单元格正确加载,但在其他所有单元格中图像都无法加载。下面是我的代码:
this.origImage = (ParseFile) posts.get(position).get("image");
try {
Log.d("MyMessage", "Gonna convert image");
this.imageData = this.origImage.getData();
this.options = new BitmapFactory.Options();
this.options.inDither = true;
this.options.inPreferredConfig = Bitmap.Config.ARGB_8888;
this.options.inSampleSize = 8;
this.notConvertedYet = BitmapFactory.decodeByteArray(this.imageData, 0, this.imageData.length, this.options);
if (this.notConvertedYet != null)
this.myBitmap = rotateImage(90, this.notConvertedYet);
else
this.myBitmap = this.notConvertedYet;
mHolder.picImageView.setImageBitmap(this.myBitmap);
Log.d("MyMessage", "Converted image");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}到底发生了什么让事情变得一团糟?
发布于 2014-09-21 09:02:00
当它绑定到列表适配器时,
posts.get(position).get("image");真的吗?parse SDK是否在解析文件CDN中的实际URL上为网络Http GET调用了一系列AsyncTasks?
您可能需要了解更多关于它所做的事情的信息,因为正如Adapter.getView()所使用的那样,它的效率可能不是很高……
任何图像加载器框架,如Volley,如Universal image Loader,如AQuery,都将像一个应用程序接口一样工作,您可以在其中进行调用,提供图像的ImageView和CDN URL作为参数。该框架将为所有图像处理多线程、池化Parse.com连接、memCache和fileCache。当使用parse将位图存储在CDN文件中时,您仍然可以使用任何图像加载框架。
适配器中的AQuery示例...
ImageView thumbnail=(ImageView)vi.findViewById(R.id.imageView1); // thumb image
mAquery.id(thumbnail).width(110).image($thumbUrl_CDN,
true, true, 0, R.drawable.default_video, null, 0, mAspectRatio); 你的代码看起来没问题..也许所有循环都是黑色的原因是适配器没有时间通过网络加载文件,并且imageViews语句没有阻塞UI线程??
https://stackoverflow.com/questions/25952984
复制相似问题