moha safi
moha safi

Reputation: 51

How can I display custom view same as when long pressed on search icon on below image?

This is image How can I dislay custom view same as when long pressed on search icon on below image?

my code

Upvotes: 1

Views: 166

Answers (2)

Dipak Sharma
Dipak Sharma

Reputation: 976

You can define title property in your menu file like below.


<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_call"
    android:title="Call"
    app:showAsAction="always"
    android:icon="@android:drawable/ic_menu_call" />
</menu>

If you not using menu, then just add below code into your onCreate method.


TooltipCompat.setTooltipText(your_view_id, "Your message here")

Upvotes: 2

Siddharth Thakkar
Siddharth Thakkar

Reputation: 376

the feature you want to implement is called "Tooltip". Android default provides us to add a Tooltip to the View.

TooltipCompat.setTooltipText(imgSearch, "Your tooltip string here")

// "imgSearch" is your View/button/anything you want to add Tooltip to when user Long Presses it.

Upvotes: 3

Related Questions