2

我正在使用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?
        }
4

0 回答 0