我正在使用Groupie填充我的RecyclerView,并且试图在我的RecyclerView中使用删除按钮才能正常工作。我想出了如何使用setOnItemClickListener
在活动中执行此操作,但我希望仅在单击删除按钮时才调用侦听器:
val adapter = GroupAdapter<ViewHolder>()
...
recycleview_my_cards.adapter = adapter
...
//this works
adapter.setOnItemClickListener { item, view ->
val userCardItem = item as UserCardItem
val id = userCardItem.userCreditcard.id
if (id != null) {
deleteCard(id)
}
startActivity(intent)
finish()
}
findViewById<Button>(R.id.deleteCreditCard)?.setOnClickListener {
//how should this be done?
}