安卓应用专用软键盘 [英] android app specific soft keyboard

查看:16
本文介绍了安卓应用专用软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Android 上创建特定于应用的软键盘?在阅读了 InputMethodService 文档并查看了替代键盘应用程序之后,我认为替代键盘只能配置为系统范围使用(通过设置 -> 区域设置和文本).

Is there a way to create an app specific soft keyboard on Android? After reading about InputMethodService docs and checking out alternative keyboard apps out there, I figure the alternate keyboard can only be configured for system wide usage (through Settings -> Locale and Text).

如果上述问题的答案是否定的,那么是否至少有一种方法可以加载自定义字典并覆盖系统键盘的默认字典(仅当我的应用程序正在使用时)?当用户只敲击几个键时,这将有助于向用户提供非常相关的建议.

If the answer to above question is no, then is there at least a way to load a custom dictionary and override the default dictionary of the system keyboard (only when my app is in use)? That will help in giving very relevant suggestions to the user when he has only tapped couple of keys.

推荐答案

如果你只想要一个看起来和行为都像软键盘的 View,我在 我的 SmallKeyboard 类.您只需要扩展 android.inputmethodservice.KeyboardView 并决定布局.请参阅该文件末尾的 onKey 和 onText 方法,了解按键被按下时所执行的操作.

If you just want a View that looks and acts like a soft keyboard, I did that in my SmallKeyboard class. You just need to extend android.inputmethodservice.KeyboardView and decide on layout. See the onKey and onText methods at the end of that file for the action taken when keys are pressed.

代替我的键盘模型内部类,您可以从 XML 加载它 如果您的密钥集相当稳定.

Instead of my keyboard model inner class, you could load it from XML if your key set is fairly constant.

这篇关于安卓应用专用软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆