# TooltipCompat

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/widget/TooltipCompat.java+class:androidx.appcompat.widget.TooltipCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***


```
public class TooltipCompat
```

<br />

*** ** * ** ***

Helper class used to emulate the behavior of `https://developer.android.com/reference/android/view/View.html#setTooltipText(java.lang.CharSequence)` prior to API level 26.

## Summary

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/appcompat/widget/TooltipCompat#setTooltipText(android.view.View,java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html tooltipText)` Sets the tooltip text for the view. |

## Public methods

### setTooltipText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static void setTooltipText(@NonNull View view, @Nullable CharSequence tooltipText)
```

Sets the tooltip text for the view.

On API 26 and later, this method calls through to `https://developer.android.com/reference/android/view/View.html#setTooltipText(java.lang.CharSequence)`.

Prior to API 26, this method sets or clears (when tooltipText is `null`) the view's `OnLongClickListener` and `OnHoverListener`. A tooltip-like sub-panel will be created on long-click or mouse hover.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view` | the view on which to set the tooltip text |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html tooltipText` | the tooltip text |