在我的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