编写一个使用KeyEvents将文本插入文本字段的Android系统应用.但是扩展的unicode字符不可打印 [英] Writing a Android System app that uses KeyEvents to insert text into a text field. But Extended unicode characters are not printable

查看:53
本文介绍了编写一个使用KeyEvents将文本插入文本字段的Android系统应用.但是扩展的unicode字符不可打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我可以将CTL +用于控制字符,将SHIFT +用于诸如A,B之类的大写字母和诸如!,{(即基本拉丁字符和标点符号)之类的字符.

但是我无法在Android中找到Ã,dž...等符号的组合. Ubuntu使用CTRL + SHIFT + U ..的组合,后跟四个生成符号的数字,但这似乎无法翻译为Android.

TL; DR:如何使用Android KeyEvents和KeyCharacter Map生成特殊符号?

更新:了解到该资源: https://source. android.com/devices/input/key-character-map-files ,看来我将不得不使用组合键,而且它们谈论的是不可思议的十六进制输入,但是我尝试使用

1111,后跟Alt + Shift + X(qwerty.kcm文件包含此文件)...但是它不会在相应的1111上键入Unicode符号.

有人可以帮忙吗?

解决方案

能够弄清楚.

第1步:更新Android操作系统的kcm文件(大多数情况下为Generic.kcm).下面的示例是带有"X"符号的示例.按钮,但实际上可以应用于任何按钮.添加alt + shift行为,并将魔术十六进制代码添加到alt + shift + X的组合中.

key X {
    label:                              'X'
    base:                               'x'
    shift, capslock:                    'X'
    alt+shift:                          '\uef00'
}

第2步: 在应用程序服务中为1,2,3,4生成关键事件,然后为Alt + Shift + X生成关键事件,您将可以在屏幕上打印字符ሴ".

阅读这些参考资料以获取更多信息.

https://source.android.com/devices/input/key-character-map-files
https://developer.android.com/reference/android/view/KeyEvent
https://android.stackexchange.com/questions/38405/how-to-insert-unicode-characters-by-their-hex-codes-using-usb-keyboard-on-ics

So I could use a combination of CTL+ for control characters , SHIFT+ for Upper case letters like A ,B and characters like !,{ (i.e Basic Latin and punctuation characters) .

However I am not able to find the combination in Android for symbols like Ã,dž ... etc. Ubuntu Uses a combination of CTRL+SHIFT+U .. followed by four numbers that generate the symbol, but that does not seem translatable to Android.

TL;DR : How to generate special symbols using Android KeyEvents and KeyCharacter Map?

Update : Learnt about this resource : https://source.android.com/devices/input/key-character-map-files and it looks like I will have to use a key combo and they talk about a magic hex input , but I have tried using

1111 followed by Alt+Shift+X ( qwerty.kcm file contains this) ... But it does not type out the unicode symbol to the corresponding 1111.

Can someone help with this please ?

解决方案

Was able to figure it out .

Step 1 : Update your Android OS's kcm file (most of the cases its Generic.kcm) . The example below is with the "X" button but it can be applied to any button really . Add the alt+shift behavoir and assing the magic hex code to the combination of alt+shift+X.

key X {
    label:                              'X'
    base:                               'x'
    shift, capslock:                    'X'
    alt+shift:                          '\uef00'
}

Step 2: Generate Keyevents for 1,2,3,4 followed by a keyevent for Alt+Shift+X in your applications service and you will be able to print the character "ሴ" .

Read these Resources for further information.

https://source.android.com/devices/input/key-character-map-files
https://developer.android.com/reference/android/view/KeyEvent
https://android.stackexchange.com/questions/38405/how-to-insert-unicode-characters-by-their-hex-codes-using-usb-keyboard-on-ics

这篇关于编写一个使用KeyEvents将文本插入文本字段的Android系统应用.但是扩展的unicode字符不可打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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