0
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;
}
任何人都可以解釋我的overridded方法的參數。 [
getView(int position, View convertView, ViewGroup parent)
]。我需要知道每個參數做什麼?夫婦對自定義適配器類問題我有一個靜態類ViewHolder持有我的視圖組件,那麼爲什麼我創建一個nerw實例
holder
。
http://stackoverflow.com/a/3864111/1168654 –