android - 视图卡在 InputConnection 的 `commitText` 方法上
问题描述
当用户使用中的键码按下键时,我正在提交文本InputConnection
但是这种方法会挂起视图并在几毫秒后释放
if (getCurrentInputConnection() != null) {
getCurrentInputConnection().commitText(String.valueOf((char) charCode), 1);
}
我是在做错什么,还是有其他解决方案?
解决方案
为什么不直接从创建一个实例getCurrentInputConnection()
?
String txt = String.valueOf((char) charCode);
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ic.commitText(txt , 1);
}
推荐阅读
- sql - 我无法使用从案例表达式创建的唯一变量列表创建表
- python - Python 'ascii' 编解码器无法在位置 10 编码字符 u'\xf6'
- linux - 并行运行 shell 脚本循环
- powershell - 无法从 ldap 组导出用户和 emplyeeid
- objective-c - 在 macOS 上检测用户注销
- javascript - 页面重新加载后锚标记停止工作
- sql - 为表生成唯一标识符
- amazon-web-services - 在多个 s3 存储桶上自动化和应用存储桶策略的最佳方法是什么?
- c# - 为什么这个二维数组初始化是非法的?
- spring-integration - Spring Integration 5.1 - 集成流测试 - dsl