Android 4.0 EditText 光标对于 editable=false 始终不可见
在我的应用程序中,我想要一个不接受任何输入的 EditText
,即 XML 布局中的 android:editable="false"
或 setKeyListener(null)
代码> 在代码中。
我只想以一种非常受控的方式添加字符,因此我总是使用 setText()
以编程方式添加它,并且我不希望显示任何虚拟键盘。但是,我仍然需要 EditText
中有一个可见的光标,以便用户知道将在何处插入编程输入。
在 Android 4.0 之前,这很容易实现 (android:editable="false"
)。在 4.0 中,光标显然被删除了。我已经尝试过 android:cursorVisible="true"
但它不起作用。
有谁知道如何在 Android 4.0 中既拥有可见光标又抑制输入?真的很感谢这里的任何帮助。
In my app I want an EditText
that doesn't accept any input, i.e. android:editable="false"
in XML layout or setKeyListener(null)
in code.
I only want to add characters in a very controlled manner, and so I always add it programmatically with setText()
and I don't want any virtual keyboard to show up. However, I still need a visible cursor in the EditText
so that the user will know where the programmatic input will be inserted.
This was very easy to implement (android:editable="false"
) until Android 4.0. In 4.0, the cursor was apparently removed. I've tried android:cursorVisible="true"
but it doesn't work.
Does anyone know how to both have a visible cursor and still suppress input in Android 4.0? Really grateful for any help here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请尝试
Please Try
在 EditText 中设置 android:focusable=false。
Set android:focusable=false in your EditText.
我有类似的问题。尝试使用:
它对我有用。有关详细信息,请参阅 http://code.google.com/p/android /问题/详细信息?id=27609
I had similar problem. Try using:
it worked for me. For more details see http://code.google.com/p/android/issues/detail?id=27609