Android : Regarding the behavior of onTouchEvent with onDraw?

on Monday, October 13, 2014


I am creating a Customized View and I have on-draw() method and onTouchEvent Listener with three actions DOWN, MOVE and UP and I am also calling invalidate() from inside it.


And I am tracing the behavior of the Touch Listener by placing some Logstatements. One of the Log statements is placed inside onDraw() and it is Log.i(TAG,"@onDraw()") and the other one is placed inside the onTouchListener and it is Log.i(TAG,"@onTouchEvent");.


Waht I expected when I touch the screen is to see the following on the console:



@onTouchEvent()
@onDraw()
@onTouchEvent()
@onDraw()
@onTouchEvent()
@onDraw()


But, what the console displayed was:



@onTouchEvent()
@onDraw()
@onTouchEvent()
@onDraw()
@onTouchEvent()
@onDraw()
@onTouchEvent()
@onTouchEvent()
@onDraw()


Why for every single touch on the screen the @onTouchevent is called five time while I have only three events DOWN, MOVE, UP?


0 comments:

Post a Comment