我从Firestore带来了信息,它很好地完成了列表,但是在单击的那一刻,听到了声音,但是它起作用了。
val card_view = CardView(this)
card_view.id = idCardV
val layoutParams = LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT
)
layoutParams.bottomMargin = 15
card_view.layoutParams = layoutParams
card_view.setContentPadding(6,6,6,6)
card_view.setCardBackgroundColor(Color.LTGRAY)
card_view.radius = 12F
card_view.cardElevation = 8F
card_view.maxCardElevation = 12F
card_view.isClickable = true
card_view.callOnClick()
card_view.setOnClickListener { View.OnClickListener{
Toast.makeText(baseContext, "éxito 5", Toast.LENGTH_SHORT).show()
} }
答案 0 :(得分:0)
尝试放入card_view .focuseable = true
和
card_view.setOnClickListener {
Toast.makeText(baseContext, "éxito 5", Toast.LENGTH_SHORT).show()
}
答案 1 :(得分:0)
更改
card_view.setOnClickListener { View.OnClickListener{
Toast.makeText(baseContext, "éxito 5", Toast.LENGTH_SHORT).show()
} }
到
card_view.setOnClickListener {
Toast.makeText(baseContext, "éxito 5", Toast.LENGTH_SHORT).show()
}