Android的Viewholder实施 [英] Android Viewholder implementation
问题描述
我理解的理念和 Viewholder使用模式,但还是我有一个问题:
假设我们在viewholder 1 TextView的,而10个项目显示(item0,ITEM1 ......)。
如果我称之为 findViewById
一次,因为我知道我有TextView中的一个对象。
因此,在第一次调用getView我膨胀的观点,找到参考,并设置文本item0。
在第二个电话,我得到相同的TextView并设置文本ITEM1到同一个TextView的。
为什么项目0文本不会更改?
有背景中的任何克隆?
是否有背景中的任何克隆?
Android的preallocate的若干意见认为足以填补你在哪里运行应用程序(的意见池)设备,从内容的角度相同,但不同于基准角度
的屏幕I understand the idea and usage of Viewholder pattern, but still I have one question:
Assume we have one TextView in the viewholder, and 10 items to display ("item0, item1....").
If I call findViewById
once, as I understand I have one object of that TextView.
So at first call to getView I inflate the view, find the reference and set text "item0".
At second call I get same TextView and set text "item1" to the same TextView.
Why item 0 text doesn't change?
Is there any cloning in the background?
Is there any cloning in the background?
Android preallocate a number of views that are enough to fill the screen of the device where you are running the app ( a pool of views ), identical from the content perspective but differently from the reference perspective
这篇关于Android的Viewholder实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!