Android的Viewholder实施 [英] Android Viewholder implementation

查看:174
本文介绍了Android的Viewholder实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解的理念和 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆