Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onStart() {
- super.onStart();
- FirebaseRecyclerAdapter<Comments, CommentsViewHolder> firebaseRecyclerAdapter
- = new FirebaseRecyclerAdapter<Comments, CommentsViewHolder>(
- Comments.class,
- R.layout.comment,
- CommentsViewHolder.class,
- MarkersRef
- )
- {
- @Override
- protected void populateViewHolder(CommentsViewHolder viewHolder, Comments model, int position) {
- viewHolder.setUsername((model.getUsername()));
- viewHolder.setComment(model.getComment());
- viewHolder.setDate(model.getDate());
- viewHolder.setTime(model.getTime());
- }
- };
- CommentsList.setAdapter(firebaseRecyclerAdapter);
- }
- public static class CommentsViewHolder extends RecyclerView.ViewHolder
- {
- View mView;
- public CommentsViewHolder(@NonNull View itemView) {
- super(itemView);
- mView = itemView;
- }
- public void setUsername(String username)
- {
- TextView myUserName = (TextView) mView.findViewById(R.id.username_comment);
- myUserName.setText(username+ " ");
- }
- public void setComment(String comment)
- {
- TextView myComment = (TextView) mView.findViewById(R.id.comment_text);
- myComment.setText(comment);
- }
- public void setDate(String date)
- {
- TextView myDate = (TextView) mView.findViewById(R.id.date_comment);
- myDate.setText(" Date: " + date);
- }
- public void setTime(String time)
- {
- TextView myTime = (TextView) mView.findViewById(R.id.time_comment);
- myTime.setText(" Time: " + time);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement