Skip to content

Instantly share code, notes, and snippets.

@mbeaty
Created November 29, 2013 01:31
Show Gist options
  • Save mbeaty/7700379 to your computer and use it in GitHub Desktop.
Save mbeaty/7700379 to your computer and use it in GitHub Desktop.
Android ViewHolder pattern rework
An alternative to the traditional Google-recommended ViewHolder pattern. This implementation you don't have to create a ViewHolder class per view:
https://github.com/BoD/jraf-android-util/blob/master/src/org/jraf/android/util/ui/ViewHolder.java
"Example usage, in your adapter:
TextView name = ViewHolder.get(convertView, R.id.name);
(As you can see you can even skip the cast because of the generics trick.)"
Quote reference: BoD comment here: http://daniel-codes.blogspot.com/2013/11/is-findviewbyid-slow.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment