Я действительно присвоил бы это, если бы кто-нибудь мог помочь мне.
Я применяю свой второй RecyclerView с настраиваемым объектом кнопки смахивания, здесь забавный handleSwipeClick настроен для обработки действия.
У меня вопрос: как я могу сделать эту функцию ( handleSwipeClick ) для конкретной обработки каждой строки ?? Нравится Удалить этот элемент строки
Адаптер # 1
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = baxters[position]
holder.listItem_time.text = item.intakeTime
holder.itemView.dose_recycler_view.apply {
dose_recycler_view.setHasFixedSize(true)
layoutManager = LinearLayoutManager(context)
dose_recycler_view.layoutManager = layoutManager
//Swipe action
val swipe = object: SwipeHelper(context,dose_recycler_view, 400){
override fun instaniateSwipeButton(
viewHolder: RecyclerView.ViewHolder,
buffer: MutableList<SwipeButton>
) {
// Adding Buttons
buffer.add(
SwipeButton(context,
"",
30,
R.drawable.ic_check_circle,
Color.parseColor("#66ff66"),
object : ButtonClickListener {
override fun handleSwipeClick(id: Int) {
// Click action
// TODO call to change LAST TAKEN and NEW INTAKE
Companion.errorToast(
context,
"Medicijn ingenomen. $id"
)
}
})
)
}
}
adapter = ClientDoseListAdapter(item.doses.toMutableList())
setRecycledViewPool(viewPool)
}
}
Адаптер # 2
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = doses[position]
/// DELETE THIS ROW
holder.med_name.text = item.medicineItem.name
holder.dose_amount.text = item.amount.toString()
}