Android 4.0 EditText 光标对于 editable=false 始终不可见

发布于 2025-01-01 00:58:51 字数 491 浏览 2 评论 0原文

在我的应用程序中,我想要一个不接受任何输入的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不…忘初心 2025-01-08 00:58:51

请尝试

 android:clickable="false"

Please Try

 android:clickable="false"
栀子花开つ 2025-01-08 00:58:51

在 EditText 中设置 android:focusable=false。

Set android:focusable=false in your EditText.

江南烟雨〆相思醉 2025-01-08 00:58:51

我有类似的问题。尝试使用:

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);

它对我有用。有关详细信息,请参阅 http://code.google.com/p/android /问题/详细信息?id=27609

I had similar problem. Try using:

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);

it worked for me. For more details see http://code.google.com/p/android/issues/detail?id=27609

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文