which one is better to use?
It really depends on your requirement.
onTouch
gives you Motion Event. Thus, you can do a lot of fancy things as it help you separate state of movement. Just to name a few:
- ACTION_UP
- ACTION_DOWN
- ACTION_MOVE
Those are common actions we usually implement to get desire result such as dragging view on screen.
On the other hand, onClick
doesn’t give you much except which view user interacts. onClick
is a complete event comprising of focusing,pressing and releasing. So, you have little control over it. One side up is it is very simple to implement.
do we need to implement both?
It is not necessary unless you want to mess up with your user. If you just want simple click event, go for onClick
. If you want more than click, go for onTouch
. Doing both will complicate the process.
From User point of view, it is unnoticeable if you implement onTouch
carefully to look like onClick
.