Advertisement
vinaysshenoy

Fast ListView scroll without ViewHolder Pattern

Apr 20th, 2013
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public View newView(Context context, Cursor cursor, ViewGroup parent) {
  2.  
  3.     View view = LayoutInflater.from(context).inflate(R.layout_my_view, null);
  4.  
  5.     TextView tv = (TextView) view.findViewById(R.id.text1);
  6.     ImageView iv = (ImageView) view.findViewById(R.id.image1);
  7.  
  8.     view.setTag(R.id.text1, tv);
  9.     view.setTag(R.id.image1, iv);
  10.  
  11.     return view;
  12. }
  13.  
  14. public void bindView(View view, Context context, Cursor cursor) {
  15.  
  16.     ((TextView) view.getTag(R.id.text1)).setText(cursor.getString(cursor.getColumnIndex(COL_TEXT_1)));
  17.     ((ImageView) view.getTag(R.id.image1)).setImageResource(R.drawable.image);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement