I have RecyclerView and I set to each item OnTouchListener and OnClickListener
OnTouchListener:
override fun onBindViewHolder(holder: ItemListViewHolder, position: Int) {
val item = getItem(position)
holder.bind(item)
holder.itemView.cardview.setOnTouchListener { v, event ->
if (event.action == MotionEvent.ACTION_DOWN) {
Log.d(TAG, "onBindViewHolder: $event.buttonState")
this.startDragListener.onStartDrag(holder)
}
return@setOnTouchListener true
}
}
OnClickListener:(inside the view holder)
init {
itemView.setOnClickListener(this)
}
override fun onClick(v: View?) {
onItemClickListener.onItemClick(adapterPosition)
}
The problem is when I click on the item, only the startDragListener triggered, but the on click event never triggered.
I read some similar question on stackoverflow about this problem, but most of them are very old/deprecated method
How can I solve this problem and handle both touch listeners and click listeners?