Questions tagged [onlongclicklistener]

A Listener object that reacts to the click of a Mouse input device, where the button is depressed for an extended period of time before being released.

A OnLongClickListener is a listener object that reacts to the click of a Mouse input device, where the button is depressed for an extended period of time before being released. This type of listener is become much more prevalent since the introduction of smart phones, where a LongClickEvent is triggered from the user holding their finger on the screen for a few seconds.

329 questions
153
votes
10 answers

how to implement a long click listener on a listview

I want to add OnLongClickListener on my list view. Whenever the user long press the item in list some action should be performed, But my code does not catch this listener. Please let me know where I am going wrong. The similar code works for…
techayu
  • 1,673
  • 2
  • 14
  • 13
129
votes
4 answers

Android: Why does long click also trigger a normal click?

I have a ListView with listeners for a long click and a regular click. Why, when I long press a list item, the regular click event gets called too? I need to have two separate functions for the different clicks.
mellowg
  • 1,736
  • 3
  • 15
  • 19
39
votes
4 answers

Use both onClickListener and onLongClickListener in listview Android 1.6

I am using both onClickListener and onLongClickListener for a TextView in a ListView. I see that in Android 1.6, the long click listener is fired along with the on click listener meaning both are fired when I long click. But this is not the case in…
dcanh121
  • 4,509
  • 10
  • 34
  • 80
38
votes
5 answers

How to properly use setOnLongClickListener() with Kotlin

I've been trying to set up a long click listener event, but keep getting the following error: Type mismatch. Required:Boolean Found:Unit I've had no issues with the setOnClickListener event, but for some reason I'm having zero luck with the…
Dylan Hargett
  • 383
  • 1
  • 3
  • 4
38
votes
4 answers

Handle on item long click on recycler view

I have an adapter that customizes a recyclerView and I want to open a popup menu on long click event on recyclerView's items. How can I do this?
26
votes
2 answers

Android - Why does onItemLongClick(...) return a boolean?

Coming from a Java background I am used to dealing with actions though I'm not really sure why the method requires a boolean is returned and don't fully understand the explanation given on the site: true if the callback consumed the long click,…
Tim
  • 978
  • 4
  • 15
  • 34
23
votes
1 answer

OnLongItemClick in RecyclerView

I am starting to use RecyclerView in Android. Things work fine until I implement touch listener for my adapter. From this topic: https://stackoverflow.com/a/26826692/2923403 I can implement the listener for childview correctly. However, I would like…
Souris
  • 281
  • 1
  • 4
  • 13
13
votes
3 answers

How to prevent OnItemClickListener work when long click performed?

I have a gridview and i want its items to act different if user performs click or long click that is why i am using OnItemClickListener and OnItemLongClickListener but when long click happens both listeners react.I want to perform only…
Tony
  • 1,513
  • 1
  • 20
  • 39
13
votes
1 answer

setOnClickListener and setOnLongClickListener call on single button issue

I need your help if any one can be, it will be great thing for my solution. I don't know is it possible or not, but I want to try to fix this out any how.. Actually I want to implement two method on single button click event, its simple click and…
jt.
  • 253
  • 2
  • 5
  • 16
12
votes
1 answer

Calling delete method in custom content provider

I am learning Android and I am stuck on an issue involving calling a custom content provider. I have been using an example in an instructional book and although it describes how to create the custom provider there is no clear example how to call the…
11
votes
6 answers

onTouchEvent onClick onLongClick calls

In our application, we handle the events in a button to record data. So initially when I use setOnLongClickListener() and setOnClickListener() together with the same button, it work fine for us. That means it will call both this listener base on the…
AndroidDev
  • 4,331
  • 21
  • 73
  • 123
9
votes
3 answers

Stop OnLongClickListener from firing while dragging

I have a custom View with bitmaps on it that the user can drag about. I want to make it so when they long click one of them I can pop up a context menu with options such as reset position etc. In the custom View I add my…
8
votes
1 answer

Android to detect when you are holding down a button

I need to be able to tell when the user is holding a button down and when the user lets go. This is different from onClickListener and onLongClickListener. How would i go about doing something like this? For example I press a button that starts a…
The Tokenizer
  • 1,546
  • 3
  • 28
  • 46
7
votes
2 answers

Implement Drag & Drop in Gingerbread

I need to know how I can implement Drag & Drop in Android for the Gingerbread version. As I know Gingerbread doesn't support that by default. What I have coded: a ViewGroup class to hold dynamic added child, each child should after a long click be…
7
votes
2 answers

onLongClickListener never get trigered

I have a custom listView defined like this public class DDListView extends ListView implements OnScrollChangedListener { than I make an instance of it with name mExampleList I set onLongClickListener but it never get called, where is my problem…
Lukap
  • 29,596
  • 60
  • 146
  • 239
1
2 3
21 22