在我的ListView中,每行都有一个ImageView和两个TextView。 ListView的图片从我的Galaxy Nexus的内存中加载。我已经将它缩减到100x100使用ListView中的位图:缓慢加载
Bitmap scaled = Bitmap.createScaledBitmap(de, 80, 80, true);
但它仍然需要几秒钟加载。
我该怎么办?
编辑:
public Bitmap resizeBitmap(String path){
BitmapFactory.Options options = new BitmapFactory.Options();
InputStream is = null;
try {
is = new FileInputStream(path);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BitmapFactory.decodeStream(is,null,options);
try {
is.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
is = new FileInputStream(path);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// here w and h are the desired width and height
options.inSampleSize = Math.max(options.outWidth/100, options.outHeight/100);
// bitmap is the resized bitmap
Bitmap bitmap = BitmapFactory.decodeStream(is,null,options);
return bitmap;
}
使用lazyloading – mukesh 2013-05-14 11:32:21