它是至关重要的性能有ViewHolder静态的ViewHolder模式? [英] Is it crucial for performance to have ViewHolder as static in a ViewHolder pattern?

查看:139
本文介绍了它是至关重要的性能有ViewHolder静态的ViewHolder模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它是至关重要的性能有ViewHolder静态的 ViewHolder模式

  

一个ViewHolder对象存储的每个标签内组件意见   布局的领域,这样你就可以立即访问他们没有   需要反复找一找。首先,你需要创建一个类来   握住你的具体意见集。例如:

 静态类ViewHolder {
  TextView的文字;
  TextView的时间戳;
  ImageView的图标;
  进度进展情况;
  INT位置;
}
 

解决方案

这不是对性能是至关重要的,它是关于使用。如果 ViewHolder 类不会是一成不变的 - 你必须提供父类的实例:

  Type类型的任何包围实例访问。
必须符合分配类型类型的封闭情况
(例如x.new A()其中x是类型的实例)。
 

Is it crucial for performance to have ViewHolder as static in a ViewHolder pattern?

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;
}

解决方案

It's not crucial for performance, it is about using. If ViewHolder class will not be static - you have to provide instance of parent class:

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).

这篇关于它是至关重要的性能有ViewHolder静态的ViewHolder模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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