Android RecyclerView Crud(insert,update,delete,View) List Tutorial with Example

By | June 8, 2019
RecyclerView Crud Operation Insert,Update,Delete And View in Android Tutorial Example

What is RecyclerView in Android ?

RecyclerView is a more advanced version of ListView with improved performance and other benefits.  RecyclerView is  introduced in Marshmallow. RecyclerView is extends the ViewGroup class and implements ScrollingView interface.

Recycler view allow different layout manager. It is Linear Layout,Grid Layout And Staggered Grid Layout are easy to Creates. Recycler view use to ViewHolder store reference of the view.

RecyclerView Layout Managers

LinearLayoutManager : In this layout used to supports both vertical and horizontal lists.

StaggeredLayoutManager : In this layout used to supports staggered lists.

GridLayoutManager : In this layout used to supports displaying grid item in GalleryView.

What is ViewHolder in Android ?

A ViewHolder class is inner static class in your adapter which holds reference to the views. It is objects are managed by an adapter, which you create by extending the RecyclerView.Adapter abstract class.

Adapter to bind view holders data.It is assigning the view holder position and call adapter onBindViewHolder() method.

RecyclerView is used to CardView Layout in UI Design.It is more Flexible and smooth design in cardView.

What is CardView in RecyclerView Android ?

CardView is introduce in Material Design. CardView can represent the information in a card manner with shadow (elevation) and corner radius. it is consistent across the platform. CardView extends the FrameLayout and it is supported.

You can good looking UI you can used to combine cardView with recyclerView.

CardView Attributes in Android

card_view:cardCornerRadius : In this Attribute Used to set the corner radius in our layouts

card_view:cardBackgroundColor : In this Attribute Used to set the background color of the cardView.

RecyclerView And CardView Dependency Implement

implementation ‘com.android.support:recyclerview-v7:28.0.0

implementation ‘com.android.support:cardview-v7:28.0.0

In this tutorial to make crud operation in listView. we can used to array list and then in this list maintain add item delete item view item and update item in recyclerView.

Create activity_main.xml File Follow this Code.

Create item_row.xml File Follow this Code.

Now i have Create Dialog to display user can update the Information in List.

Create dialog_update.xml File Follow this Code.

Create UserData.java Class File follow this Code.

Create MainActivity.java File Follow this code.

Create MyAdapter.java Class File follow this code.

Create ItemClickListerner.java interface File follow this code.

In this Example of Create Simple RecyclerView and create custom layout file to bind recyclerView adapter. now i have create another update dialog layout file when user can click update button to display dialog and update the information in list item. when you can enter name and email and then click to add button then add in list of recyclerView.

you can add item in list then display recyclerView list item.and then right side two button is edit and delete.you can click to edit button icon then open the dialog box and then edit information and display updated item at a time. you can press delete icon then deleted item in list and then refreshed automatically in recyclerView.

I have create custom adapter in recyclerView and create holder in recyclerView. holder is used to xml views binding resources and then adapter to get and set data of xml layout file and count number of display item in getItemCount() method.it is return of list of size. Now i have Create custom interface in adapter listener. it is used to user can click edit and delete button icon then to called this interface method in adapter.