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

由网友(坏脾滊)分享简介:它是至关重要的性能有ViewHolder静态的 ViewHolder模式? 一个ViewHolder对象存储的每个标签内组件意见布局的领域,这样你就可以立即访问他们没有需要反复找一找。首先,你需要创建一个类来握住你的具体意见集。例如:静态类ViewHolder {TextView的文字;TextView的时间戳;Ima...

它是至关重要的性能有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).

阅读全文

相关推荐

最新文章