如何在EditText中的提示后将焦点设置为文本? [英] How to set focus to the text after the hint in EditText?

查看:139
本文介绍了如何在EditText中的提示后将焦点设置为文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很感兴趣,你可以在EditText提示符后设置焦点到文本?如果没有这样的属性为XML布局?在这里,我仍然看起来像这样。



需要



最快和工作的答案给予Asok

我也发现了一个类似的方式:

EditText.append(60); // 60或您在EditText中的文字 提示文本后面的光标,如果这是正确的,那么它是不可能的,你必须删除提示,并使用 setText ,而不是像这样:

  EditText et =(EditText)findViewById(R.id.sixtyseconds); 
et.setText(60);
et.setSelection(et.getText()。length());


I'm interested in you can set the focus to the text after the prompt to EditText? If no such attribute for xml layout? At the moent I still looked like this.

need

EDIT :
The fastest and working answer given Asok
I also found a similar way:
EditText.append("60"); // 60 or your text in EditText

解决方案

If I understand correctly you are looking to place the cursor behind the hint text, if this is correct then it is not possible, you'll have to remove hint and use setText instead, like so:

EditText et = (EditText)findViewById(R.id.sixtyseconds);
et.setText("60");
et.setSelection(et.getText().length());

这篇关于如何在EditText中的提示后将焦点设置为文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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