Please help How to handle the double click  on event  OnClicklistener on the button, Cardview or others,
            Asked
            
        
        
            Active
            
        
            Viewed 756 times
        
    0
            
            
        
        Shalu T D
        
- 3,921
 - 2
 - 26
 - 37
 
        Sekuntum Rosela
        
- 7
 - 3
 
- 
                    1Checkout this, https://stackoverflow.com/questions/4849115/implement-double-click-for-button-in-android – taug Jul 26 '19 at 01:58
 
1 Answers
1
            Please try below:-
Java Version:-
 private var doubleClickLastTime = 0L
    view.setOnClickListener {
            if(System.currentTimeMillis() - doubleClickLastTime < 300){
                doubleClickLastTime = 0
                doAction()
            }else{
                doubleClickLastTime = System.currentTimeMillis()
            }
        }
Kotlin Version:-
val doubleClickLastTime = 0L
view.setOnClickListener
run({ if (System.currentTimeMillis() - doubleClickLastTime < 300)
     {
       doubleClickLastTime = 0
       doAction()
     }
     else
     {
       doubleClickLastTime = System.currentTimeMillis()
     } })
        Shalu T D
        
- 3,921
 - 2
 - 26
 - 37