Luis A. Florit
Luis A. Florit

Reputation: 2609

How to prevent a longclick while scrolling a TextView in Android?

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.

Upvotes: 0

Views: 1048

Answers (1)

Broatian
Broatian

Reputation: 870

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

Upvotes: 1

Related Questions