Hi,
I would like my app to change page if the trackball is moved to the
right/left. This works but unfortunately the app is sent a stream of
trackball events and changes several pages instead of just 1.
Is there a way to handle just the first of a stream of track ball
events if the user moves the trackball right or left.
Here is the code I currently use:
@Override
public boolean onTrackballEvent(MotionEvent event) {
boolean isHandled = false;
try {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE: {
float currentX = event.getX();
if (currentX < -0.5) {
CurrentPassage.getInstance().previousChapter();
isHandled = true;
} else if (currentX > 0.5) {
CurrentPassage.getInstance().nextChapter();
isHandled = true;
}
break;
}
}
if (!isHandled) {
isHandled = super.onTrackballEvent(event);
}
} catch (Exception e) {
Log.e(TAG, "Error changing page", e);
}
return isHandled;
}
Thanks
Martin
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en