So I have a TextView that resides inside a fragment in my activity. I'm trying to add a gestureDetector to that TextView so that the user can carry out certain actions that pertain to it. I especially want the swipe or fling. My code is as follows:
public void onViewCreated(View view, Bundle savedInstanceState)
{
myGestDetector = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener());
TextView mainTextView = (TextView)getView().findViewById(R.id.HourCount);
mainTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
myGestDetector.onTouchEvent(motionEvent);
return false;
}
});
}
@Override
public boolean onDown(MotionEvent motionEvent) {
return false;
}
@Override
public void onShowPress(MotionEvent motionEvent) {
}
@Override
public boolean onSingleTapUp(MotionEvent motionEvent) {
return false;
}
@Override
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float v, float v2) {
return false;
}
@Override
public void onLongPress(MotionEvent motionEvent) {
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
Log.d("GESTURES", "onFling: " + event1.toString()+event2.toString());
return true;
}
The issue is that I cannot get any of these to fire. I've tried doing the fling several times, but the log isn't showing that I am calling the onFling. Does anyone have any idea what I'm doing wrong?