krasnoff
krasnoff

Reputation: 967

Handle OnTouch Event inside an Activity

Im Trying to handle an OnTouch Event inside an activity But I am unable to Handle MotionEvent.ACTION_UP Action. here is my code:

boardView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction())
            {
            case MotionEvent.ACTION_DOWN:
                showToastNotification("ACTION_DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                showToastNotification("ACTION_UP");
                break;
            }

            return false;
        }



    });

Why Is That?

Thanks in advance

Kobi

Upvotes: 0

Views: 3433

Answers (3)

krasnoff
krasnoff

Reputation: 967

The "onTouch" event has to return "true" istead of "false".

Upvotes: 4

GSree
GSree

Reputation: 2898

Could be (Guess) When ACTION_DOWN happens, the Toast appears and the Activity is not in control of ACTION_UP. Or.. as @C0deAttack said, it might be behind the scenes. Use ACTION_DOWN notification as Toast.short and ACTION_UP as Toast.long .. OR you could use LogCat.

Upvotes: 0

C0deAttack
C0deAttack

Reputation: 24667

Do you see the "ACTION_DOWN" toast? Is it just the "ACTION_UP" toast which does not show?

Upvotes: 0

Related Questions