gpt4 book ai didi

android - 在 ViewHolder 模式中将 ViewHolder 设为静态对性能至关重要吗?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:11 28 4
gpt4 key购买 nike

ViewHolder pattern 中将 ViewHolder 设为静态对性能至关重要吗? ?

A ViewHolder object stores each of the component views inside the tag field of the Layout, so you can immediately access them without the need to look them up repeatedly. First, you need to create a class to hold your exact set of views. For example:

static class ViewHolder {
TextView text;
TextView timestamp;
ImageView icon;
ProgressBar progress;
int position;
}

最佳答案

性能不重要,重要的是使用。如果 ViewHolder 类不是静态的 - 您必须提供父类的实例:

No enclosing instance of type Type is accessible. 
Must qualify the allocation with an enclosing instance of type Type
(e.g. x.new A() where x is an instance of Type).

关于android - 在 ViewHolder 模式中将 ViewHolder 设为静态对性能至关重要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12368302/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com