Yogesh
Yogesh

Reputation: 1216

android - How to raise an event on drag on the screen

Scenario: I have 3 imageviews,call these as A,B & C. these are placed one after the another(in series) on the screen. now if i drag my finger from A to C, event of imageview B should raise. Please suggest.

Thanks

Upvotes: 1

Views: 451

Answers (2)

gvaish
gvaish

Reputation: 9404

You'll need to handle the touch event (override onTouchEvent or setOnTouchListener of View; or override onTouchEvent of Activity), and do the following:

  1. getActionMasked and check for ACTION_DOWN. Set a flag, say, isDown = true
  2. getActionMasked and check if(isDown && getActionMasked() == ACTION_MOVE) and do your work.
  3. Additionally in multi-touch mode, you may want to getPointerCount to handle multiple ACTION_DOWN events.

Upvotes: 1

LuxuryMode
LuxuryMode

Reputation: 33741

Use a GestureDetector and supply the Maths of dragging from A to C. Then when that MotionEvent occurs, perform the event.

Upvotes: 1

Related Questions