which is better to use?
It really depends on your requirement. onTouch gives you a Motion Event. This way you can do a lot of bizarre things, as it helps you share the state of movement. Just to name a few
- ACTION_UP
- ACTION_DOWN
- ACTION_MOVE
These are the usual actions that we usually implement to get the result of desire, for example, dragging a view onto the screen.
OnClick, on the other hand, does not give you much, except that the viewing user interface interacts. onClick is a complete event consisting of focusing, clicking and releasing. Thus, you have little control over this. One side is very simple to implement.
do we need to implement both?
This is not necessary if you do not want to spoil your user. If you just need a simple click event, go to onClick. If you want more than just a click, go to onTouch. Performing both will complicate the process.
From the user's point of view, itβs imperceptible if you carefully implement onTouch to look like onClick.
PH7 03 Feb '12 at 2:40 2012-02-03 02:40
source share