'android kotlin detect hover in recycler view
I want to detect hover for each element in recycler view. I tried setOnTouchListener but it works for only one item which is my first pressed item. For the other items i have to press one by one. But i want to make this with dragging (such as css hover or c# MouseEnter event). How Can i do this?
@SuppressLint("ClickableViewAccessibility", "SetTextI18n")
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
val txt = arrayList.get(position)
holder.title.text = txt
//holder.layout.setOnClickListener {
// holder.layout.setBackgroundResource(R.drawable.circle2)
// }
holder.layout.setOnTouchListener(View.OnTouchListener { v, event -> //show dialog here
val action = event.action
when (action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_MOVE -> {
if (event.action == MotionEvent.ACTION_MOVE) {
holder.layout.setBackgroundResource(R.drawable.circle2)
//DO STUFFS IN HERE
}
}
}
true
})
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


