tags:

views:

44

answers:

1

How do you create a button in an Android app 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
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
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