2014-01-17 96 views
2

我必須開發一個應用程序,其中我必須顯示帶有大listrow的listview。 我想使用一個圖像加載器,它可以在後臺下載圖像並以平滑和快速滾動顯示。圖像加載器與緩存?

現在我用下面這些裝載機鏈接:

http://commondatastorage.googleapis.com/androiddevelopers/shareables/training/BitmapFun.zip http://www.androidhive.info/2012/07/android-loading-image-from-url-http/

但滾動不順暢和快速,因爲我想要的。任何人都可以提供一個鏈接或源代碼來解決我的問題。

+2

https://github.com/nostra13/Android-Universal-Image-Loader 谷歌是你的朋友,順便說一句 – FWeigl

+0

@Ascorbin我已經使用這個鏈接。不是很有用。 –

+3

使用畢加索。 https://github.com/square/picasso – Musterknabe

回答

1

您可以使用BitmapRegionDecoder,並設置BitmapFactory.Options一些像:

選項。 inSampleSize = 10;

如:

AssetManager asset = MainActivity.this.getAssets(); 
InputStream istr = asset.open("big_image.jpeg"); 

BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(istr, false); 

BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inSampleSize = 10; // or greater 

// here you get the new bitmap with its new size.  
Bitmap bitmap = decoder.decodeRegion(new Rect(0, 0, decoder.getWidth(), decoder.getHeight()), options);