Skip to content

Instantly share code, notes, and snippets.

@konk3r
Last active March 20, 2016 22:04
Show Gist options
  • Save konk3r/96c63c2a4e3ded48e3f2 to your computer and use it in GitHub Desktop.
Save konk3r/96c63c2a4e3ded48e3f2 to your computer and use it in GitHub Desktop.
public class ViewHolder extends RecyclerView.ViewHolder {
TextView textView;
public ViewHolder(View itemView) {
super(itemView);
// Look up all of your views here, findViewById can be somewhat costl
// so you don't want to do it every time the view is recycled
textView = ((ViewGroup)itemView).findViewById(R.id.my_text_view);
}
public void bind(Model model) {
// reset all of your views here
textView.setColor(defaultColor);
textView.setText(model.getText());
etc
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment