android viewholder example
Example 1: viewholder
class PostsVH(itemView : View)
: RecyclerView.ViewHolder(itemView)
{
fun bind(get : UserPosts?) {
itemView.txt_userId.text = get?.userId.toString()
itemView.txt_id.text = get?.idPost.toString()
itemView.txt_title.text = get?.title
itemView.txt_body.text = get?.body
}
}
Example 2: recyclerview layout oncreatw
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_listitem,parent,false);
ViewHolder Holder = new ViewHolder(view);
return Holder;
}