문제

I have a long list of icons (about 30) in my layout, so I am getting an OutOfMemory error in Android 2.3.3.

What I want to do is creating Drawable object if only necessary (icon is visible on the current scroll).

But how to now if imageview is on the screen or not? I couldn't find a listener for this.

My icons (png files) are already in drawables folder. There is no downloading process at all.

도움이 되었습니까?

해결책

Try to use ImageLoader Library which provide you lots of custom option to load list with Images...enter link description here

다른 팁

This is how I solved my problem;

Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.icon1);
Bitmap loBitmap = Bitmap.createScaledBitmap(image, iconSize , iconSize, true);
imageView.setImageBitmap(loBitmap);

iconSize was already calculated in my case.

I didn't want to use an external library for such simple task, so I give up with lazy loading and just get rid of OOM exception.

Because of my question is about listening for view entering the screen event, I will mark @Swap-IOS-Android's answer as the answer. You can check out the library source to see how it works.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top