Last active
August 10, 2016 18:43
-
-
Save mplacona/055aca66853f2d8085d9fbe63ecc6a33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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