我可以设置类似"提示"在Android的一个看法? [英] Can I set something like "tooltip" for a view in android?

查看:105
本文介绍了我可以设置类似"提示"在Android的一个看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以设置一些消息,看起来像一个工具提示为一个TextView或按钮?

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

推荐答案

有徘徊在触摸屏的概念,但你可以设置一个<一个href="http://developer.android.com/reference/android/view/View.OnLongClickListener.html">LongClickListener为您的浏览,并有吐司似乎经过了漫长的preSS。事情是这样的:

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();
    }
});

编辑:看了您的评论后,你应该只使用提示属性在你的EditText XML布局:

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

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

这篇关于我可以设置类似&QUOT;提示&QUOT;在Android的一个看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆