0

In an Android app I have a TextView that can be scrolled, clicked and longclicked. My problem is that when I scroll the TextView it also thinks it's being longclicked.

I tried something like:

TV.setOnTouchListener(new View.OnTouchListener() {
    scrolled = false;
    public boolean onTouch(View v, MotionEvent event) {
       if(event.getAction() == MotionEvent.ACTION_MOVE) {
            System.out.println("SCROLLED!!");
            scrolled = true;
        return true;
       }
    }
 });

But I can see it's being scrolled when longclicked and not moved (maybe too sensitive?). I tried with MotionEvent.ACTION_SCROLL, the logical option, but it doesn't even react (????).

I really have no idea what else to try.

Suggestions?

Thanks!

L.

Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58

1 Answers1

1

In case you handle your own longclick detection like here Then you would just cancel the longpress callback as soon as you detect a MotionEvent.ACTION_MOVE.

In case you use the OnLongClickListener you can find a solution here

Community
  • 1
  • 1
Broatian
  • 860
  • 9
  • 10