Stay organized with collections
Save and categorize content based on your preferences.
View.OnLongClickListener
public
static
interface
View.OnLongClickListener
android.view.View.OnLongClickListener
|
Known indirect subclasses
ZoomButton |
This class was deprecated
in API level 26.
Use other means to handle this functionality. This widget is merely a
simple wrapper around a long-press handler.
|
|
Interface definition for a callback to be invoked when a view has been clicked and held.
Summary
Public methods
onLongClick
public abstract boolean onLongClick (View v)
Called when a view has been clicked and held.
Parameters |
v |
View : The view that was clicked and held. |
Returns |
boolean |
true if the callback consumed the long click, false otherwise. |
onLongClickUseDefaultHapticFeedback
public boolean onLongClickUseDefaultHapticFeedback (View v)
Returns whether the default HapticFeedbackConstants.LONG_PRESS
haptic feedback
is performed when this listener has consumed the long click. This method is called
immediately after onLongClick(View)
has returned true.
Parameters |
v |
View : The view that was clicked and held.
This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# View.OnLongClickListener\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nView.OnLongClickListener\n========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/view/View.OnLongClickListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nView.OnLongClickListener\n`\n\n\n`\n\n\n`\n\n|---------------------------------------|\n| android.view.View.OnLongClickListener |\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [ZoomButton](/reference/android/widget/ZoomButton) |----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | [ZoomButton](/reference/android/widget/ZoomButton) | *This class was deprecated in API level 26. Use other means to handle this functionality. This widget is merely a simple wrapper around a long-press handler.* | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface definition for a callback to be invoked when a view has been clicked and held.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[onLongClick](/reference/android/view/View.OnLongClickListener#onLongClick(android.view.View))`(`[View](/reference/android/view/View)` v) ` Called when a view has been clicked and held. |\n| ` default boolean` | ` `[onLongClickUseDefaultHapticFeedback](/reference/android/view/View.OnLongClickListener#onLongClickUseDefaultHapticFeedback(android.view.View))`(`[View](/reference/android/view/View)` v) ` Returns whether the default [HapticFeedbackConstants.LONG_PRESS](/reference/android/view/HapticFeedbackConstants#LONG_PRESS) haptic feedback is performed when this listener has consumed the long click. |\n\nPublic methods\n--------------\n\n### onLongClick\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean onLongClick (View v)\n```\n\nCalled when a view has been clicked and held.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----|----------------------------------------------------|\n| `v` | `View`: The view that was clicked and held. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------------------------|\n| `boolean` | true if the callback consumed the long click, false otherwise. \u003cbr /\u003e |\n\n### onLongClickUseDefaultHapticFeedback\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic boolean onLongClickUseDefaultHapticFeedback (View v)\n```\n\nReturns whether the default [HapticFeedbackConstants.LONG_PRESS](/reference/android/view/HapticFeedbackConstants#LONG_PRESS) haptic feedback\nis performed when this listener has consumed the long click. This method is called\nimmediately after [onLongClick(View)](/reference/android/view/View.OnLongClickListener#onLongClick(android.view.View)) has returned true.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----|---------------------------------------------------------------------------------|\n| `v` | `View`: The view that was clicked and held. This value cannot be `null`. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | true to perform the default [HapticFeedbackConstants.LONG_PRESS](/reference/android/view/HapticFeedbackConstants#LONG_PRESS) haptic feedback, or false if the handler manages all haptics itself. \u003cbr /\u003e |"]]