我在Dialog中有简单的画廊,一切都很好但是现在当我有一些照片时我需要滚动查看它所有过程都不能顺利进行。我读到这样做的好习惯是使用Glide lib,所以我尝试使用代码:
Glide.with(mContext)
.load(listFiles.get(position).toString()) //path to picture
.into(iv);
但它对我不起作用。
现在我这样做,就像我说的那样有效但不顺利
GridView的:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null)
{
convertView = LayoutInflater.from(mContext).inflate(R.layout.my_grid, parent, false);
}
ImageView iv = (ImageView) convertView.findViewById(R.id.imageView);
//setting different width and height for different screen sizes
Bitmap compressed = decodeScaledBitmapFromSdCard(listFiles.get(position).toString(),mContext.
getResources().getInteger(R.integer.width),mContext.getResources().getInteger(R.integer.height));
ExifInterface exifInterface=null;
try {
exifInterface = new ExifInterface(listFiles.get(position).getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
//rorating bitmap
Bitmap rotate = delayedMessageService.rotateBitmap(compressed,exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL));
iv.setImageBitmap(rotate);
return convertView;
}
我做错了什么以及它应该如何看待?
答案 0 :(得分:2)
尝试替换此
Glide.with(mContext)
.load(listFiles.get(position).toString()) //path to picture
.into(iv);
用这个
Glide.with(mContext)
.load(listFiles.get(position).getAbsolutePath()) //path to picture
.into(iv);