I'm new to Android and have been stuck with this issue for sometime now. I'm trying to implement a customized clock in my app using imageviews on top and bottom of fields which shows the number-data of the hour or minute. What I have so far accomplished of doing was implementing a touchevent on these imageviews to either increase my time or to decrease my time.
One feature that I am trying to add into this is to have my textviews recognize "fling" motion of the user and go increasing/decreasing based on the direction of the fling.
To do this, I have been searching on the web for these "fling" implementations of which I have found to be the following:
minute.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, final MotionEvent event) {
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
minute.dispatchTouchEvent(e);
Log.d("fling", "down");
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
minute.dispatchTouchEvent(event);
Log.d("fling", "Flinged.");
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
};
return false;
}
});
which, I have put into the onTouchEvent of my minute
textview field.
With or without the minute.dispatchTouchEvent
lines within my onDown and onFling methods, I do not get any logs in my logcat, from which I assume that this gesturemotion is not being dispatched to my minute field.
How do I resolve this issue? Thanks in advance for help :D
Issue resolved via using NumberPicker to simulate the a digital clock.
To my app's requirements, I set the wrap to false and min and max value to be reversed to have the "fling down" action simulate incrementing the desired time.