RecyclerView + CardView - Part 5 - Delete Item using swipe - Android Studio Tutorial
Автор: Phuc VR
Загружено: 2020-09-16
Просмотров: 1048
Описание:
Hi guys! I'm Phuc VR
In this tutorial, We will learn how to delete an item in recyclerView using swipe
We have recyclerView. We remove the item by swipe item to the left or the right. So look like smooth and cool. Let's get started.
First, Create a new class ...... that extend ItemtouchHelper.CallBack and write the constructor
The first parameter in supper adds support for dragging the recycler view item up or down. We don't care about that hence. So giving here is zero. The second parameter is to pass Simplecallback information about left and right swipes.
Next, we need to override onSwiped(). This is called when an item is swiped off the screen. You can leave it as is.
The deleteItem() method does not exist yet but we’ll implement it in the adapter.
In the adapter, we need to implement the deleteItem() method we called in SwipeToDeleteCallback earlier
In mainactivity create a new ItemTouchHelper using our SwipeToDeleteCallback and attach it to the RecyclerView.
-----------------------------------------------------------------------
Donate Me:
paypal.me/nguyenphucnick
For the beginner:
• Android Studio Tutorial basic for beginner
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: