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
。
答案 0 :(得分:0)
对于getView方法: