由网友(少年多沧桑)分享简介:我如何添加一个占位符文字的EditText 中,是不是在XML中的类?我在code以下的EditText 将在alertdialog显示出来:最后的EditText名=新的EditText(本);解决方案 嗯,好吧。你要找的是什么 setHint(INT)。简单地传递从XML字符串的资源ID,你是好去。 修改和XML格...![教程 金山WPS中文本占位符的特点与使用](/d/file/2023/09-17/4800ce4481b2b3fb272b4c4aaf9c6646.png)
我如何添加一个占位符文字的EditText
中,是不是在XML中的类?
我在code以下的EditText
将在alertdialog显示出来:
最后的EditText名=新的EditText(本);
解决方案
嗯,好吧。你要找的是什么 setHint(INT)
。简单地传递从XML字符串的资源ID,你是好去。
修改
和XML格式,它只是安卓提示=someText
![教程 金山WPS中文本占位符的特点与使用](/d/file/2023/09-17/4800ce4481b2b3fb272b4c4aaf9c6646.png)
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"
相关推荐
最新文章