My layout contain one header in which i inculded in each Activity, in this header there is a image button. Is it possible to write a common onClick event for this imageButton??
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.
You can write a class that extends OnClickListener and the onClick method. Then in each activity’s onCreate method, find the ImageButton and set its onClickListener to that class:
In your activities:
EDIT: Sorry, of course implements.
EDIT2: See updated code for Context reference.