I was wondering how do i attach this(OnGenericMotionListener) listener inside an activity. Do i have to register it to each view? thanks
note: please provide code.
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.
To add any interface to a class in java you just need to add the word implements and then the class name to the top of the activity declaration. So to add the OnGenericMotionListener you would use the code below.
This would set the GenericMotionListener for myView so when the event occurs it will call the onGenericMotion function inside of your activity. If you want to attach it to multiple views just use a switch on the id of the view passed to the onGenericMotion function.