How to Generate TouchEvent?
I Have drawn a set of images(balls) on a SurfaceView. Now am trying to make the image(ball) i touch to disappear. Am having those images in a collection. Am not understanding how to generate touch event on individual ima开发者_如何学Cge. Can any one provide some help on this?
Thank You Yashwanth.B
Supposing you have an ImageView
, you should implement the onTouchEvent(MotionEvent event)
method.
You could use the Android utility "sendevent" to generate a touch event and should be able be found it at /system/bin/, if you know the coordinate of your image.
You also need to know the device node of your touch panel, assuming it is event1
/system/bin/sendevent /dev/input/event1 1 330 1
/system/bin/sendevent /dev/input/event1 3 0 x
/system/bin/sendevent /dev/input/event1 3 1 y
/system/bin/sendevent /dev/input/event1 0 0 0
/system/bin/sendevent /dev/input/event1 1 330 0
Here x, y represent your coordinate of your image.
精彩评论