Try to use ImageLoader Library which provide you lots of custom option to load list with Images...enter link description here
How to listen for imageview is on screen?
-
26-06-2022 - |
题
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.
解决方案
其他提示
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.