J'essaie de comprendre comment voir lorsqu'un événement de mouvement est fait avec un événement (c.-à-d., L'utilisateur a appuyé sur l'écran, a traîné et a retiré son doigt de l'écran). Dans les Docs, je ne vois que getEventTime à générer lorsque l'événement a commencé, mais il n'y a aucune mention sur la façon de comprendre quand il a fini. Des idées?découvrir quand un MotionEvent est terminé
4
A
Répondre
5
Il y a MotionEvent.ACTION_UP
et MotionEvent.ACTION_DOWN
drapeau sont là
Vous pouvez vérifier en comparant avec event.getAction()
vous pouvez utiliser comme cette
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
//now touched
break;
case MotionEvent.ACTION_UP:
//your code
break;
}
}
Il y a beaucoup de drapeaux, Cochez cette case MotionEvent
Questions connexes
- 1. Pour savoir quand un NSThread est terminé
- 2. Comment savoir quand un IntentService est terminé?
- 3. Comment savoir quand un geste est terminé
- 4. Activer div quand un autre est terminé
- 5. détecter quand uploadValues est terminé?
- 6. Savoir quand DataBinding est terminé
- 7. comment savoir quand un travail dans un thread est terminé?
- 8. Quand le getView est-il terminé?
- 9. Comment savoir quand l'initialiseur d'objet est terminé
- 10. Webkit GTK :: Comment détecter quand un téléchargement est terminé?
- 11. Comment savoir quand un élément XAML est terminé chargement
- 12. Comment savoir quand un geste de pincement est terminé (UIGestureRecognizer)
- 13. Comment savoir quand un processus s'est terminé?
- 14. Comment savoir quand scan terminé
- 15. MotionEvent Initialiser?
- 16. Tracer un MotionEvent dans un ViewGroup
- 17. Vérifier quand le fb-like est terminé chargement
- 18. Android: Comment savoir quand le service est terminé
- 19. Comment savoir quand mon lot d'appels EAP est terminé?
- 20. Smart gwt. Comment déterminer quand le chargement est terminé
- 21. IO.popen (my_cmd) - quand le sous-processus est-il terminé?
- 22. Comment savoir quand INSERT MySQL est terminé (connexions multiples)
- 23. Faire quelque chose quand $ .get est complètement terminé
- 24. WMIC MangementClass RemoteCommand - détermine quand il est terminé? STDOUT?
- 25. Comment puis-je déterminer quand Dispatcher.BeginInvoke est terminé?
- 26. Jmeter - Comment savoir quand le test est terminé?
- 27. Le contact est terminé quand il existe encore
- 28. Microsoft Surface: Quand le storyboard # terminé est-il appelé?
- 29. Comment puis-je savoir quand [OpenFeint initialize ....] est terminé?
- 30. Animation OnTouchListener (MotionEvent)
merci , je l'ai juste compris il y a une demi-heure avec le même code :) – jfisk