A android library lo handle double click on android Views components. You just need to call it on your view onCLickListener
.
- Android API level 14 or greater
- Your favorite IDE
The current version is: 3.0
Gradle:
Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
implementation 'com.github.pedromassango:doubleClick:CURRENT-VERSION'
Maven:
Step 1. register jitpack.io
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Step 2. Add the dependency
<dependency>
<groupId>com.github.pedromassango</groupId>
<artifactId>doubleClick</artifactId>
<version>CURRENT-VERSION</version>
</dependency>
The class DoubleClick
extends from View.OnClickListener
so, just call the DoubleClick
class on you onClickListener
of the view that you wish to listen, and pass a instance of DoubleClickListener
class to listen the events.
See the sample code below:
Button btn = new Button(this);
btn.setOnClickListener( new DoubleClick(new DoubleClickListener() {
@Override
public void onSingleClick(View view) {
// Single tap here.
}
@Override
public void onDoubleClick(View view) {
// Double tap here.
}
});
// use this to define your own interval
// }, 100));