如何防止软键盘出现触摸(How to prevent soft keyboard from appearing on touch)

编程入门 行业动态 更新时间:2024-10-11 17:27:45
如何防止软键盘出现触摸(How to prevent soft keyboard from appearing on touch)

当触摸特定的EditText时,我不希望软键盘出现。 但我仍然希望能够根据用户请求显示软键盘(例如,按下按钮时)并允许用户编辑文本。 我知道如何显示/隐藏软键盘,我只是不知道如何防止它出现在触摸上。 有什么建议怎么办?

一般的想法是,用户将主要处理文本中的选择/位置,并且仅偶尔输入字符。 在选择或导航文本时,我不希望软键盘减少可见的文本量。

I don't want the soft keyboard to appear when a particular EditText is touched. But I still want to be able to show the soft keyboard upon user request (say, when a button is pressed) and allow the user to edit the text. I know how to show/hide the soft keyboard, I only don't know how to prevent it from appearing on touch. Any suggestion how to do it?

The general idea is that the user will be mostly working with selection/position within the text, and only occasionaly entering characters. I don't want the visible amount of text to be reduced by the soft keyboard when selecting or navigating the text.

最满意答案

简单地用

txtEdit.setShowSoftInputOnFocus(false);

当你想启用它时,反转上面的过程

simply use

txtEdit.setShowSoftInputOnFocus(false);

and when you want to enable that , reverse above process

更多推荐

本文发布于:2023-08-06 08:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1446869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何防止   键盘   prevent   soft   appearing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!