public static class ViewHolder{
public TextView item1;
public TextView item2;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
ViewHolder holder;
if (v == null) {
LayoutInflater vi =
(LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.document_item_row, null);
holder = new ViewHolder();
holder.item1 = (TextView) v.findViewById(R.id.big);
holder.item2 = (TextView) v.findViewById(R.id.small);
v.setTag(holder);
}
else
holder=(ViewHolder)v.getTag();
final DocumentResponse custom = entries.get(position);
if (custom != null) {
holder.item1.setText(custom.getCreateByFullName());
holder.item2.setText(custom.getTitle());
}
return v;
}
谁能解释一下覆盖方法的参数。[
getView(int position, View convertView, ViewGroup parent)
]。我需要知道每个参数的作用是什么?我有一个静态类 ViewHolder 持有我的视图组件,那我为什么要创建一个 nerw 实例
holder
。