RecyclerView example in android java
RecyclerView example in android java

Hey Guys, This article will help you to better understand the implementations of RecyclerView in android with your own adapter and custom layout.

for more android an coding related stuff visit my channel

Full video tutorial is here :

Part 1 : Creating RecyclerView & Adapter

Part 2 : Adding & Removing Items from RecyclerView on Run Time

you can find latest dependency for RecyclerView on the official google android developer page.

Copy code for adapter and follow Part 1 video instructions how to can use or make adapter for your recyclerview.

package com.raj.recyclerviewexample;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class TodoAdapter extends RecyclerView.Adapter<TodoAdapter.MyViewHolder> {

    Context context;
    ArrayList<TodoItem> todoItems;


    public TodoAdapter(Context context, ArrayList<TodoItem> todoItems) {
        this.context = context;
        this.todoItems = todoItems;

    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.rv_item_layout, parent, false);
        return new MyViewHolder(view);

    public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {;

        if (todoItems.get(position).getComplete()) {
        } else {

        holder.delete.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {




    public int getItemCount() {
        return todoItems.size();

    public class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv;
        CheckBox ch;
        ImageView delete;

        public MyViewHolder(@NonNull View itemView) {

            tv = itemView.findViewById(;
            ch = itemView.findViewById(;
            delete = itemView.findViewById(;


Thanks for reading this article i hope it will help you learn recyclerview in android. follow my and subscribe to my channel to learn more about coding and life style.

visit my channel

Categories: Android


Leave a Reply

Your email address will not be published. Required fields are marked *