Skip to content

Instantly share code, notes, and snippets.

@mplacona
Last active August 10, 2016 18:43
Show Gist options
  • Save mplacona/055aca66853f2d8085d9fbe63ecc6a33 to your computer and use it in GitHub Desktop.
Save mplacona/055aca66853f2d8085d9fbe63ecc6a33 to your computer and use it in GitHub Desktop.
public class NoteRecyclerViewAdapter extends RealmBasedRecyclerViewAdapter<
Note, NoteRecyclerViewAdapter.ViewHolder> {
public NoteRecyclerViewAdapter(
Context context,
RealmResults<Note> realmResults) {
super(context, realmResults, true, false);
}
public class ViewHolder extends RealmViewHolder {
private TextView mText;
private TextView mDate;
public ViewHolder(RelativeLayout container) {
super(container);
this.mText = (TextView) container.findViewById(R.id.tv_text);
this.mDate = (TextView) container.findViewById(R.id.tv_date);
}
}
@Override
public ViewHolder onCreateRealmViewHolder(ViewGroup viewGroup, int viewType) {
View v = inflater.inflate(R.layout.note_item, viewGroup, false);
return new ViewHolder((RelativeLayout) v);
}
@Override
public void onBindRealmViewHolder(ViewHolder viewHolder, int position) {
final Note note = realmResults.get(position);
viewHolder.mText.setText(note.getText());
viewHolder.mDate.setText(note.getDate().toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment