简体   繁体   English

Android在选择文本时禁用显示软键盘

[英]Android Disable showing soft-keyboard on selecting text

on EditText when i select text, soft-keyboard show automatically by android, how can i disable showing keyboard on selecting text? 当我选择文本时,在EditText上,Android会自动显示软键盘,如何禁用选择文本时显示键盘?

i found many solution about hide or disable showing keyboard, but i can't find any solution about disable that on selecting text. 我发现了许多有关隐藏或禁用显示键盘的解决方案,但是我找不到有关禁用文本选择的任何解决方案。 is any solution to resolve this problem? 有解决此问题的解决方案吗?

If you do not want keyboard when you click in edit text that means you do not want it to be editable. 如果您在单击编辑文本时不想要键盘,则意味着您不希望它是可编辑的。 To do so disable the edittext 为此,禁用edittext

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="Hello there I am edit text"
    android:enabled="false"/>

when you get into the condition when you want it to be enabled, enable it from code 当您希望启用该条件时,从代码中启用它

edittext.setEnabled(true);

But the chances are that your use case might be valid for usage of TextView . 但是,您的用例可能对TextView使用有效。 Because if you dont want keyboard, it means you do not want to edit it by typing, which is what Textview Does. 因为如果您不想使用键盘,则意味着您不想通过键入来编辑它,这就是Textview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM