Voici la solution que je suis arrivé à la fin Si elle est une aide à tout le monde:
private static Method GetPointCountMethod;
private boolean mIsTouchMove = false;
private static boolean mTapable = true;
static {
// Check if the getPointerCount method is availabe (aka api level 5)
try {
GetPointCountMethod = MotionEvent.class.getMethod("getPointerCount");
/* success, this is a newer device */
}
catch (NoSuchMethodException nsme) {
/* failure, must be older device */
}
};
// Invoke the getPointCount Method if it exists
private int getPointCount(MotionEvent event)
{
try {
return (Integer) GetPointCountMethod.invoke(event);
}
catch (IllegalArgumentException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
return -1;
}
@Override
public boolean dispatchTouchEvent(MotionEvent event)
{
// Set the tappable to be only when the map is realy just tapped and not moved or zoomed
if (event.getAction() == MotionEvent.ACTION_UP) {
if (GetPointCountMethod != null) {
if (getPointCount(event) == 1) {
if (mIsTouchMove) {
mIsTouchMove = false;
}
else {
mTapable = true;
// Finaly - a Tap! :
}
}
}
}
else if (event.getAction() == MotionEvent.ACTION_MOVE) {
mTapable = (false);
mIsTouchMove = true;
}
// let the rest do their job
return super.dispatchTouchEvent(event);
}
Il n'y a toujours pas de support pour la version 1.6 et c'est pourquoi cela est encore ouvert attendre de voir s'il y a un moyen pour le faire aussi dans 1.6
Hmm, c'est génial pour Android 2.0 et supérieur, que diriez-vous pour 1,6? – Jason
1.6 n'a pas de multitouch à moins d'utiliser un noyau modded. Je dirais qu'il est sûr de supposer que quiconque utilise un mod ne fonctionne pas 1.6 – schwiz