Questions tagged [ontouchlistener]

Android interface to define a callback to be invoked when a view is touched.

An Android OnTouchListener defines the callback to be invoked when the user performs an action qualified as a touch event: including a press, a release, or any movement gesture on the screen (within the bounds of the item). Learn more about input events and gestures.

1418 questions
226
votes
9 answers

HorizontalScrollView within ScrollView Touch Handling

I have a ScrollView that surrounds my entire layout so that the entire screen is scrollable. The first element I have in this ScrollView is a HorizontalScrollView block that has features that can be scrolled through horizontally. I've added an…
Joel
  • 6,033
  • 6
  • 20
  • 21
137
votes
4 answers

Android button has setOnTouchListener called on it but does not override performClick

When I try to add onTouchListner() to a button, it gets me the Button has setOnTouchListener called on it but does not override performClick warning. Does anyone know how to fix it? btnleftclick.setOnTouchListener(new View.OnTouchListener() { …
kas
  • 1,526
  • 2
  • 7
  • 13
131
votes
6 answers

onTouchListener warning: onTouch should call View#performClick when a click is detected

I have created a onTouchListener. Unfortunately onTouch() method throws me a warning: com/calculator/activitys/Calculator$1#onTouch should call View#performClick when a click is detected What does it mean? I have not found any information about…
Trzy Gracje
  • 2,309
  • 3
  • 17
  • 23
65
votes
9 answers

EditText in Listview loses focus when pressed on Android 4.x

I know there are a lot of similar questions out here but I couldn't get any of the provided solutions working in a simple sample app. The problem occurs when the softkeyboard is shown for the first time. As soon as it is shown, only by pressing the…
61
votes
11 answers

Android - Hold Button to Repeat Action

I'll admit straight off that I'm new to development and trying my hand at Android. I've been trying to search the 'net to find advice on how to implement some "Hold Button to Repeat Action" - I've created a custom numpad from buttons and want a…
Mark
  • 727
  • 1
  • 6
  • 7
60
votes
7 answers

onTouchevent() vs onTouch()

After many experiments with onTouchEvent and onTouch, I found that onTouch works everywhere you want (whether it is in activity or view) as long as you have declared the interface and put the Listener right! On the other hand, onTouchEvent only…
stelios
  • 957
  • 3
  • 13
  • 19
58
votes
6 answers

Using BottomSheetBehavior with a inner CoordinatorLayout

The design support library v. 23.2 introduced BottomSheetBehavior, which allows childs of a coordinator to act as bottom sheets (views draggable from the bottom of the screen). What I’d like to do is to have, as a bottom sheet view, the following…
52
votes
2 answers

How to handle Touch Events on a Fragment?

I'm building an interface where I need to process touch events. In particular I would to be able to enable them only to a confined area in a fragment. To better understand the problem, to respect the standards and for the goal of my application, I…
user3319400
  • 733
  • 2
  • 6
  • 10
46
votes
13 answers

Can't handle both click and touch events simultaneously

I am trying to handle touch events and click events on a button. I do the following: button.setOnClickListener(clickListener); button.setOnTouchListener(touchListener); When any one listener is registered things work fine but when I try to use them…
Ragunath Jawahar
  • 18,666
  • 20
  • 102
  • 154
34
votes
4 answers

ViewPager intercepts all x-axis onTouch events. How to disable?

Scope There is a viewpager of two fragments. One of those fragments has a layout witch listens to onTouch changes at X-axis. Problem Layout doesn't get almost all Action.Move events when touching and sliding along X-axis. It seems that viewpager has…
Oleksii Malovanyi
  • 6,600
  • 6
  • 22
  • 26
30
votes
5 answers

Handling Intercept touch event without extending ViewGroup

I have a one RelativeLayout and this layout is having nearly 10 views in it. I have set OnTouchListener to this Layout and doing some work in it and returning true. this listener is working fine when I touch the layout where there are no View (mean…
RuntimeException
  • 1,271
  • 3
  • 14
  • 24
30
votes
7 answers

OnTouchEvent not working on child views

I have a Linear Layout that has a Button and a TextView on it. I have written a OnTouchEvent for the activity. The code works fine if I touch on the screen, but if I touch the button the code does not work. What is the possible solution for this?…
user1438128
  • 493
  • 2
  • 7
  • 12
28
votes
5 answers

Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized?

Here is my code, I want to detect when my finger goes down the screen so when I touch the screen I detect the ACTION_DOWN but when I go down the screen with my finger, ACTION_MOVE is not recognized, neither ACTION_UP Do you know why? float…
morg
  • 1,161
  • 4
  • 17
  • 34
27
votes
4 answers

Kotlin OnTouchListener called but it does not override performClick

How to override performClick in Kotlin to avoid warning? next.setOnTouchListener(View.OnTouchListener { view, motionEvent -> when (motionEvent.action){ MotionEvent.ACTION_DOWN -> { val icon: Drawable =…
lambda
  • 700
  • 1
  • 8
  • 28
27
votes
3 answers

Playing default android sound of button, clicking onTouch() method

In my android app I have some buttons, that should work with onTouch() method, course I need to change button's text, when finger in ACTION_DOWN position. But this buttons should to play default android sound of button clicking (like in onClick()…
dmgmyza
  • 457
  • 2
  • 5
  • 10
1
2 3
94 95