I have a bit of doubt. I am using an image button (e.g. Play icon in media player). I want to know which action Listener I am supposed to use, onClickListener or onTouchListener
This question I also got in mind that should use click or touch listener.
Then I have my understandings like this,
When I need any View(Button/Image/etc) to make clickable
that means user just don't touch that part of screen but delebrately try to Touch on that part of screen so the next action gets called I use onClickListener
, Also another thing is like suppose working with Button we can make it Clickable True/False as per requirement dynamically,Hence in this situations the OnClickListener is preffered.
new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
}
};
While developing screens where the simple Touch of User is to be taken as action
like more in Games or Working with Images that you want to capture that where user has touched and also you need to find the Motion Events up/down/left/righ
t of the Touch I preffer to use onTouchListener
.
new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
return false;
}
};
And In your case I suggest to use the onClickListener