I would like to perform a action when an object comes into focus but only if it happens because of the hardware directional pad and not touch events. How would I go about doing this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sounds like you need to override the onKeyDownEvent method in your view or activity. The method is passed a keyCode and a KeyEvent object. Check to see if it was the directional pad. For example (in your
VieworActivityclass:Of course you can check for other codes and use a nested if or switch statement to handle several different keyCodes.