Stay organized with collections
Save and categorize content based on your preferences.
OnLongClickListener
interface OnLongClickListener
Known Direct Subclasses
ZoomButton |
This widget provides a simple utility for turning a continued long-press event into a series of clicks at some set frequency.
|
|
Interface definition for a callback to be invoked when a view has been clicked and held.
Summary
Public methods
onLongClick
abstract fun onLongClick(v: View!): Boolean
Called when a view has been clicked and held.
Parameters |
v |
View!: The view that was clicked and held. |
Return |
Boolean |
true if the callback consumed the long click, false otherwise. |
onLongClickUseDefaultHapticFeedback
open fun onLongClickUseDefaultHapticFeedback(v: View): Boolean
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
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# View.OnLongClickListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnLongClickListener\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/View.OnLongClickListener \"View this page in Java\") \n\n```\ninterface OnLongClickListener\n```\n\n|--------------------------------------------|\n| [android.view.View.OnLongClickListener](#) |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [ZoomButton](../widget/ZoomButton.html#) |------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | [ZoomButton](../widget/ZoomButton.html#) | This widget provides a simple utility for turning a continued long-press event into a series of clicks at some set frequency. | |\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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onLongClick](#onLongClick(android.view.View))`(`v:` `[View](/reference/kotlin/android/view/View)!`)` Called when a view has been clicked and held. |\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onLongClickUseDefaultHapticFeedback](#onLongClickUseDefaultHapticFeedback(android.view.View))`(`v:` `[View](/reference/kotlin/android/view/View)`)` Returns whether the default [HapticFeedbackConstants.LONG_PRESS](/reference/kotlin/android/view/HapticFeedbackConstants#LONG_PRESS:kotlin.Int) 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onLongClick(v: View!): Boolean\n```\n\nCalled when a view has been clicked and held.\n\n| Parameters ||\n|-----|-----------------------------------------------------------------------------------|\n| `v` | [View](/reference/kotlin/android/view/View)!: The view that was clicked and held. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the callback consumed the long click, false otherwise. |\n\n### onLongClickUseDefaultHapticFeedback\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onLongClickUseDefaultHapticFeedback(v: View): Boolean\n```\n\nReturns whether the default [HapticFeedbackConstants.LONG_PRESS](/reference/kotlin/android/view/HapticFeedbackConstants#LONG_PRESS:kotlin.Int) haptic feedback is performed when this listener has consumed the long click. This method is called immediately after [onLongClick](#onLongClick(android.view.View)) has returned true.\n\n| Parameters ||\n|-----|---------------------------------------------------------------------------------------------------------------|\n| `v` | [View](/reference/kotlin/android/view/View): The view that was clicked and held. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true to perform the default [HapticFeedbackConstants.LONG_PRESS](/reference/kotlin/android/view/HapticFeedbackConstants#LONG_PRESS:kotlin.Int) haptic feedback, or false if the handler manages all haptics itself. |"]]