Android Edit Text Cursor没出现 [英] Android Edit Text Cursor Doesn't Appear

查看:71
本文介绍了Android Edit Text Cursor没出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我使用以下代码禁用了键盘(我现在使用的是我的自定义键盘):

in my app I disabled the keyboard (I use now my custom keyboard) using this code:

editText.setInputType(InputType.TYPE_NULL);

现在,我的问题是文本光标不再出现在编辑文本中.我该怎么办?任何建议将不胜感激.

Now, my problem is that the text cursor does not appear anymore in the edit text. What should I do? Any suggestion would be very appreciated.

推荐答案

错误跟踪器

There is an Issue opened in bug tracker Issue opened in bug tracker for this. One of the users suggests the approach which works on "most" devices.

简而言之,您所要做的就是打电话:

Briefly, all you have to do is call:

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);

用于 EditText 视图(在调用editText.setInputType(InputType.TYPE_NULL);之后).

for your EditText view (after you called editText.setInputType(InputType.TYPE_NULL);).

您可能还应该设置:

editText.setTextIsSelectable(true);

以使文本可选(尽管in似乎无法与Samsung Galaxy SIII一起正常工作).此方法仅从 HONEYCOMB (api11)开始可用,因此在开发较旧的Android版本时请记住这一点.

in order for text to be selectable (though in does not seem to work properly with Samsung Galaxy SIII). This method is only available starting from HONEYCOMB (api11) so keep that in mind when developing for older Android versions.

此外,还指出,您的 EditText 不应是活动开始时第一个获得焦点的视图(如果是-只是从另一个视图发出的requestFocus()).尽管我(个人)对此没有遇到任何问题.

Also it is stated that your EditText should not be the first view to receive focus when activity starts (if it is - just requestFocus() from another view). Though I (personally) have not experienced any problems with this.

这篇关于Android Edit Text Cursor没出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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