How do you create a button in an Android app that produces the same result as hitting the down key on the D-Pad?
views:
44answers:
1
Q:
Android: How to create a button that produces the same result as hitting the down key on the D-Pad?
+1
A:
Send a key event of type KCODE_DPAD_DOWN. To send an event, you can use
InputMethodService.sendDownUpKeyEvents(keyEventCode);
See creating input method for more ways to send key events.
Mayra
2010-08-19 01:02:21
Thank you for the help... unfortunately i am having a hard time getting it to work... i keep getting the error: "Cannot make a static reference to the non-static method sendDownUpKeyEvents(int) from the type InputMethodService" any help would be greatly appreciated.
Frank Bozzo
2010-08-19 20:46:57
Oh, that's because sendDownUpKeyEvent isn't static, sorry the docs made it look like it was. I think that method might only apply in an IME, not an activity. See http://www.anddev.org/throwing-simulating_keystrokes_programatically-t717.html for another way to send key events.
Mayra
2010-08-23 05:30:14