自定义 EditText 的文本光标不可见
需要帮助!我创建了一个用于输入的自定义文本框。当我点击键盘时,按键附加得很好。但是由于某种原因,文本光标没有显示。我可能会错过什么?请建议。
ps我尝试了 editText.setCursorVisible(true)
我还考虑了光标与背景颜色相同的可能性..
public class ETEditText extends EditText {
public ETEditText(Context context) {
super(context);
}
public ETEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ETEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onCheckIsTextEditor() {
return false;
}
}
我发现这实际上是因为我在 onCheckIsTextEditor() 上返回 false 但如果我做到了,我会让软件键盘显示出来..我想一直隐藏它,但
有什么建议吗?
Help needed! I created a custom textbox for input. Keys append fine as I click through the keypad. However for some reason the text cursor is not showing up. What can I possibly missed? Pls advice.
p.s I tried editText.setCursorVisible(true)
I also considered the possibility that the cursor is having the same color as the background..
public class ETEditText extends EditText {
public ETEditText(Context context) {
super(context);
}
public ETEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ETEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onCheckIsTextEditor() {
return false;
}
}
I found that it was actually because I return false on the onCheckIsTextEditor()
but if I make it true I will make the software keyboard show up.. I want to hide it all the time though
any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上是因为 onCheckIsTextEditor() 返回了 false
这是由原始开发人员为了抑制键盘而完成的,这不是一个好主意,因为
它也抑制光标
It was actually because false was returned for the onCheckIsTextEditor()
That was done by the original developer for suppressing the keyboard, which is not a good idea since
it suppresses the cursor as well