アプリケーション内からギャラリーの画像/画像を開くことができます。しかし、大きな画像を取得しているときにメモリの問題が発生しています。
画像の寸法に基づいてゲラから画像を表示する方法はありますか?
この問題を解決するのを手伝ってください。
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
このリンクは、ビットマップを効率的にロードする方法、特に「縮小バージョンをメモリにロードする」の下のトピックについて説明しています。
使用しないときは、ビットマップをリサイクルする必要があります。
bitmaps.recycle();
ビットマップもハニカムから始まるヒープに保存されます。使用しないときはビットマップをリサイクルします。
http://www.youtube.com/watch?v=_CruQY55HOk . メモリ リークが発生した場合は、MAT アナライザーを使用して見つけて修正します。ビデオには、トピックに関する話があります。また、メモリの管理方法についても説明します。
多数のビットマップを表示する場合は、Universal Image Loader を使用してください。画像を表示するには、listview または grdiview を使用します。
https://github.com/nostra13/Android-Universal-Image-Loader .
Lazy List に基づいています (同じ原理で動作します)。しかし、それは他の多くの構成を持っています。より多くの構成オプションを提供するUniversal Image Loaderを使用することをお勧めします。ダウンロードに失敗した場合、エラー画像を表示できます。角を丸くした画像を表示できます。ディスクまたはメモリにキャッシュできます。画像を圧縮できます。
カスタム アダプター コンストラクターで
File cacheDir = StorageUtils.getOwnCacheDirectory(a, "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.
ニーズに合わせて他のオプションを設定できます。
遅延読み込み/ユニバーサル イメージ ローダーに加えて、ホルダーを表示してスムーズなスクロールとパフォーマンスを実現できます。http://developer.android.com/training/improving-layouts/smooth-scrolling.html .