View Holder Pattern を使わない 高速 ListView だと!?

CursorAdapter だよな、これって。

...
public View newView(Context context, Cursor cursor, ViewGroup parent) {
 
    View view = LayoutInflater.from(context).inflate(R.layout_my_view, null);
 
    TextView tv = (TextView) view.findViewById(R.id.text1);
    ImageView iv = (ImageView) view.findViewById(R.id.image1);
 
    view.setTag(R.id.text1, tv);
    view.setTag(R.id.image1, iv);
 
    return view;
}
 
public void bindView(View view, Context context, Cursor cursor) {
 
    ((TextView) view.getTag(R.id.text1)).setText(cursor.getString(cursor.getColumnIndex(COL_TEXT_1)));
    ((ImageView) view.getTag(R.id.image1)).setImageResource(R.drawable.image);

}
...

タグってやつは、便利だなあ。

[Java] Fast ListView scroll without ViewHolder Pattern - Pastebin.com

android - What bindView() and newView() do in CursorAdapter - Stack Overflow


関連ワード:  Android開発