Listener,
Interface,
Handler.
They all sound similar but they must be different.
Maybe ‘delegate’ in objective-c as well.
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.
Interface:
interfaceare used to provide roles. According to Design Patterns when there are certain behaviors that keeps changing must be encapsulated in aninterfaceor anabstract class.Eg:
Suppose there is this
paint class, which has a methodpaintIt().Now the method
paintIt()can be free-hand, shading etc, so its kind of behavior which keeps changing. So we need to encapsulate it in aninterfaceor anabstract class.Listener:
Listenersare the interface that listens to certain action, and they contains the call back methods, which has the logic that is to be fired when that particular action is done.Handler:
Handlersin android are used to post the data from the Non-UI thread to the UI thread.