In my Recyclerview I have a list of items. When I click and hold, I want to display a Dialog and dismiss it when I release it. When I just click on the button I want to open a new Activity. With the code below I have 2 problems:
1 - If I click and hold the button, Activity opens.
2 - If I click and hold the button, and slide my finger down the Dialog is not dismissed.
itemView.setOnClickListener {
openActivity()
}
itemView.setOnTouchListener { v, event ->
when(event.action){
MotionEvent.ACTION_DOWN -> {
openDialog()
return@setOnTouchListener false
}
MotionEvent.ACTION_UP -> {
dismissDialog()
v.performClick()
return@setOnTouchListener false
}
else-> {
return@setOnTouchListener false
}
}
}
How to solve this problem?