Reputation: 51
How can I dislay custom view same as when long pressed on search icon on below image?
Upvotes: 1
Views: 166
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
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