문제

I have a TextView in a fragment where I want to set different texts when the gesture is detected.

@Override
public boolean onTouchEvent(MotionEvent event) {
    this.gestureDetector.onTouchEvent(event);
    return super.onTouchEvent(event);
}

The above code is used to listen for gesture, but it can only be used in an Activity class somehow, when I put .onTouchEvent() in a fragment class, it says cannot resolve method. Any idea how I can manipulate a view from outside the fragment or any ways to basically listen for the gestures like I did in the Activity class??

도움이 되었습니까?

해결책

You can add touch listeners to views, so get the root view of that fragment, and add your listener with view.setOnTouchListener(...)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top