我正在使用 android 中的一个库连接到终端仿真器,它连接到一个串行设备(一个开关)并向我显示发送/接收的数据。我使用另一个库通过串行发送数据。在这两种情况下,我通过终端下方的文本框或通过在终端本身中键入并按键盘上的 Enter 通过连接发送数据。
但是我想禁用对终端的输入,所以我尝试将 focusable 设置为 false。不过,我仍然可以在其中输入内容,还有其他方法可以禁止在 View 中输入内容吗?
<jackpal.androidterm.emulatorview.EmulatorView
android:id="@+id/emulatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/term_entry"
android:layout_below="@+id/deviceConnect"
android:layout_toRightOf="@+id/scrllyout"
android:focusable="false"
android:focusableInTouchMode="false" />
最佳答案
查看EmulatorView的源码,看到了这个函数:
@Override
public boolean onCheckIsTextEditor() {
return true;
}
也许您可以将其更改为返回 false,看看它是否能解决您的问题。 如果这没有帮助,请检查
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {}
参见 source code
关于java - 试图禁用可聚焦,不工作,android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14440328/