0

I have a ListView which can show some AnimationDrawables that are quite memory intensive. It's unlikely more than 2 of these would be visible on screen, but there can easily be dozens in the items that make up the list.

My issues is that my ListAdapter seems to get called for every item in the list. I assume that this is so that the ListView can set it's scroll height. But it means that I'm loading all those AnimationDrawables (that use lots of memory) that I don't need.

Is there a way to determine if a call to ListAdapter is for a non visible row? This would allow me to skip loading these expensive objects that will likely never need to appear on screen.

4

1 回答 1

0

ListViews 回收行,因此任何时候只有几个不可见的行。这就是适配器的 getView 方法所做的。它创建一个视图(如果需要),并为当前项目设置数据。因此,如果您的项目多于可见行,则传递给 getView 的视图将不会为空,并且应该只是更新而不是创建。

于 2012-10-20T18:16:57.603 回答