gpt4 book ai didi

java - 如何将焦点设置到EditText中提示后的文本上?

转载 作者:行者123 更新时间:2023-12-02 00:08:55 25 4
gpt4 key购买 nike

我感兴趣的是你可以将焦点设置到提示后的文本到EditText吗?如果xml布局没有这样的属性?此刻我还是这个样子。

enter image description here

需要

enter image description here

编辑:
Asok给出的最快且有效的答案
我也找到了类似的方法:
EditText.append("60");//60 或您在 EditText 中的文本

最佳答案

提示不是真正的文本,它会在用户输入内容后消失。假设光标位于提示的末尾,当用户按下按钮并且提示消失时,您会期望什么行为?

您可以通过以下方式在 XML 中设置默认文本

android:text="60"

或通过代码

editText.setText("60");

并在焦点上通过

跳转到 EditText 的末尾
editText.setSelection(editText.getText().length());

关于java - 如何将焦点设置到EditText中提示后的文本上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13271957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com