Raghav Soodに同意します。リストビューまたはグリッドビューで画像を表示する方法をもう少し追加しました。
Universal Image loaderを使用して、リストビューに多数の画像を表示しました。
使用しないときは、ビットマップをリサイクルする必要があります。
http://www.youtube.com/watch?v=_CruQY55HOk . トークは、メモリ管理とメモリ リーク、およびそれを回避する方法についてです。メモリ リークが発生した場合は、MAT アナライザーを使用してメモリ リークを見つけることができます。このビデオでは、MAT アナライザーの使用についても説明し、メモリ リークを取り除く方法を示します。
リストビューで画像を表示するときは、ビューをリサイクルする必要があります。表示されているビューはリサイクルされません。
グリッドビューまたはリストビューで画像を表示するには、ユニバーサル画像ローダーを使用できます。遅延読み込みの改良版。画像はキャッシュされます。ローカルまたはサーバーから画像を表示できます。
https://github.com/nostra13/Android-Universal-Image-Loader
File cacheDir = StorageUtils.getOwnCacheDirectory(context, "your folder");
// Get singletone instance of ImageLoader
imageLoader = ImageLoader.getInstance();
// Create configuration for ImageLoader (all options are optional)
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
// You can pass your own memory cache implementation
.discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.enableLogging()
.build();
// Initialize ImageLoader with created configuration. Do it once.
imageLoader.init(config);
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//display stub image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();
あなたの getView() で
ImageView image=(ImageView)vi.findViewById(R.id.imageview);
imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options
ニーズに合わせて他のオプションを設定できます。
Universal Image Loader とともに、スムーズなスクロールとパフォーマンスのためにホルダーを表示できます。http://developer.android.com/training/improving-layouts/smooth-scrolling.html .
http://www.youtube.com/watch?v=wDBM6wVEO70。トークは、ビューホルダーとパフォーマンスについてです。