我有一个字符,我想将其转换为KeyEvent KeyCode约束
http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_0
如果我有一个字符’0′,我想转换成
Key code constant: ‘0’ key.
Constant Value: 7 (0x00000007)
解决方法
这是一个解决方案,我用来将字符放在webview中:
char[] szRes = szStringText.tocharArray(); // Convert String to Char array KeyCharacterMap CharMap; if(Build.VERSION.SDK_INT >= 11) // My soft runs until API 5 CharMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); else CharMap = KeyCharacterMap.load(KeyCharacterMap.ALPHA); KeyEvent[] events = CharMap.getEvents(szRes); for(int i=0; i<events.length; i++) MainWebView.dispatchKeyEvent(events[i]); // MainWebView is webview