Jump to content

Event listener and event dispatching process

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Guest_R3.RyozKidz_*

Guest_R3.RyozKidz_*
  • Guests
For onTouch listener, the function is

public boolean onTouch( View v, MotionEvent event )

based on the tutorial I'm following, it stated that return true - we have already processed the event ; return false - View itself will process the event

I can't really understand this.

#2
BlackRabbit

BlackRabbit

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 269 posts
  • Location:ten steps forward
there is mainly 2 reasons :
there is Motionevents that you are not interested in but you still need to implement them cause the interface asks for it.

And then, in the program,
it happens that when you touch in a screen area sometimes you touch over many view's area, like this : you touch a button which is inside an imageView, which is inside TableRow, which is inside a TableLayout, which is inside a ScrollView and so on.
so the touch event will fire for all those elements, but you want to process the ontouch only for the button, or for the imageview, so the other elements needs to let that event pass so it gets to the true target.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users