#How differentiate "setOnClickListener" & "setOnTouchListener"
44 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @late drum! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
wdym by "detect"
are you asking how to implement them?
No no, I have my two events, but when I only click on my phone, the setOnClickListener event and the setOnTouchListener one are started
but i want only the setOnClickListener
I don't see why you would do that. if you don't want to use the method, just don't implement it?
and also, when it touch my phone for a moment and move it on the left and right, both events are started, but i would like only the setOnTouchListener
@hallow kayak
^^
then only use that method
No I can't
I'll use deepl
wait
when I click on my phone, I want only the setOnClickListener event to run, because I want to do a certain action.
but when I drag my finger on my screen, I only want the setOnTouchListener event to fire, because I want to do another action.
But both events are launched whether I click or touch the screen
@hallow kayak
this feels like a
This is not a JavaScript server. [Java](https://en.wikipedia.org/wiki/Java_(programming_language) and JavaScript are completely different languages. See: How is JavaScript different from Java?
i'm in java, it's just a mobile app
that's why i use those events
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Someone can help me ?
don't set any listeners through setOnTouchListener
if you don't want it to been called
I want to call them
read this
but i want only the setOnClickListener
when I click on my phone, I want only the setOnClickListener event
and when I drag my finger on my screen, I only want the setOnTouchListener
I want to use two events "separately"
maybe you should use setOnDragListener instead of setOnTouchListener
what does the drag listener do ?
Register a drag event listener callback object for this View. The parameter is an implementation of View.OnDragListener. To send a drag event to a View, the system calls the View.OnDragListener.onDrag(View, DragEvent) method.
i'll look on it thanks ^^
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
np ๐
Ok I have check, and i don't think this is what i need, because i'm coding a tetris, and I need the event click to rotate 90 degrees my block. And the event to move right and left my block so I think it's the event touch and not drag, no ?
according to docs, DragEvent has different states, like ACTION_DRAG_STARTED, where you can get x and y of the point from where drag was started, so you can figure out user dragging the block or not; ACTION_DROP - Action constant returned by getAction(): Signals to a View that the user has released the drag shadow.
Thus, imo, it suits to your problem. But maybe you should ask os server dedicated to android development
Yeahh, I'm not sure it's that I wan't to do (sorry my english is very limited ๐
)
I'll ask on android development server, do you have it or not btw ?
no, sorry
Np :p thank you for your time ^^
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
you are welcome ๐