Can I set something like "tooltip" for a view in android?

Adham picture Adham · Dec 13, 2010 · Viewed 13.4k times · Source

Can I set some message to appear like a "tooltip" for a TextView or Button?

Answer

Kevin Coppock picture Kevin Coppock · Dec 13, 2010

There's no concept of "hovering" in a touch screen, but you could set a LongClickListener for your View, and have a Toast appear after a long press. Something like this:

Toast viewToast = Toast.makeText(this, "My View Tooltip", Toast.LENGTH_SHORT);

View myView = (View)findViewById(R.id.my_view);

myView.setOnLongClickListener(new OnLongClickListener() {
    @Override
    public void onLongClick(View v) {
        viewToast.show();
    }
});

EDIT: After reading your comment, you should just use the hint attribute in your EditText XML layout:

<EditText
    android:hint="My tip here" />