Clicking on an EditText, the device displays the keyboard. Is there any way, in code, I can simulate a key press? I want to use it to click on the button that changes the alphabetical keyboard pad.
Asked
Active
Viewed 6,320 times
4 Answers
4
View.dispatchKeyEvent for example

stefan bachert
- 9,413
- 4
- 33
- 40
-
do you know how to create one of these from a view class.. or an onclick listener? – baash05 Feb 03 '13 at 10:28
1
already tried smth like this?
Instrumentation inst = new Instrumentation();
for ( int i = 0; i < 10; ++i ) {
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
Thread.sleep(2000);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
Thread.sleep(2000);
}
like original author wrote there
hope you find it useful..cheers
0
Your app cannot manipulate the IME keyboard like that. You need to set the input type in code and let the device do what it wants to do. This question looks very similar to your other question: ANDROID - Numeric keyboard