开发者

How to use keyCodeToString() in Android

I want to convert keycode to its symbolic name . i.e. KEYCODE_A . A keycode is 29. In y code, onKeyDown(), when I press key 'A', I want to display what I pressed is 'A', n开发者_运维百科ot only the keycode '29'. I look up in developer.android.com, I found there is a way keyCodeToString(), it seems can do that. Any ideas how to use it?

Thanks a lot. Best, Qin


I don't think that keyCodeToString() is what you want. This will return "KEYCODE_A", when A is pressed. Perhaps you want to try getNumber or getUnicodeChar.

Since keyCodeToString is a static method, you can use it like this:

String keyCodeStr = KeyEvent.keyCodeToString(keyCode);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜