Android的占位符文本添加到的EditText [英] Android add placeholder text to EditText

查看:348
本文介绍了Android的占位符文本添加到的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个占位符文字的EditText 中,是不是在XML中的类?

我在code以下的EditText 将在alertdialog显示出来:

 最后的EditText名=新的EditText(本);
 

解决方案

嗯,好吧。你要找的是什么 setHint(INT)。简单地传递从XML字符串的资源ID,你是好去。

修改

和XML格式,它只是安卓提示=someText

How can I add a placeholder text to EditText in the class that isn't in the XML?

I have the following EditText in my code which will be shown in alertdialog:

    final EditText name = new EditText(this);

解决方案

Ah, ok. What you're looking for is setHint(int). Simply pass in a resource id of a string from your xml and you're good to go.

EDIT

And in XML, it's simply android:hint="someText"

这篇关于Android的占位符文本添加到的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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