Android的InputMethodService - 如何获得UNI code字? [英] Android's InputMethodService - how to get unicode characters?

查看:332
本文介绍了Android的InputMethodService - 如何获得UNI code字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让键盘...

int code = 29; // Key code constant: 'A' key. Constant Value: 29 (0x0000001d)
KeyEvent k = new KeyEvent(KeyEvent.ACTION_UP, code);

InputConnection ic = getCurrentInputConnection();
ic.sendKeyEvent(k);

这code送精美字母A的应用程序,因为它是与code29相关联,如从这里的 http://developer.android.com/reference/android/view/KeyEvent.html

This code nicely send letter "A" to the application, as it is associated with the code "29", as from here http://developer.android.com/reference/android/view/KeyEvent.html

不过,我该怎么办,如果我想使用UNI code字符,如在这里结果
http://en.wikipedia.org/wiki/List_of_Uni$c$c_characters

But what should I do, if I want to use unicode characters, such as in here
http://en.wikipedia.org/wiki/List_of_Unicode_characters

推荐答案

如果你正在建设一个键盘的应用程序,并在XML的键盘布局,你可以看看用户的洛朗'在另一个线程

If you are building a keyboard app, and have keyboard layout in xml, you can look at suggestion provided by user Laurent' in another thread:

<Key android:codes="946" android:keyLabel="\u03B2"/> 
<Key android:codes="946" android:keyLabel="&946;"/> 
<Key android:codes="946" android:keyLabel="β"/>  
<!-- Warning, you should use UTF-8 encoding for your project files if you use the third solution -->
<!-- all produce the same key with greek β character (unicode \u03B2, decimal 946) -->

这篇关于Android的InputMethodService - 如何获得UNI code字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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