Understanding listener with real life example

///Understanding listener with real life example

Understanding listener with real life example

Sakif Shahriar: button.setOnClickListener(new View.OnClickListener)
Sakif Shahriar: {
Sakif Shahriar: //code
Sakif Shahriar: }
Sakif Shahriar: =))
Sakif Shahriar: what happened here?
Sakif Shahriar: explain regarding OOP
kowser: when button will be clicked
kowser: it will notify to listener
kowser: our listener will be able to listen
Sakif Shahriar: button class got “setOnclick” method
Sakif Shahriar: takes “onclick listenr” from view class as parameter
kowser: and than it will execute the //code
Sakif Shahriar: 😐
Sakif Shahriar: is it so?
kowser: yes
Sakif Shahriar: 😉
Sakif Shahriar: yey, I got it
kowser: now
kowser: u can have diff type of listener
kowser: and they will be notified with diff info
kowser: say, you asked ur friend to buy a book for u, and inform u when done
kowser: asked for song to other friend
kowser: or asked for food to another friend
kowser: surely they will give u response
kowser: when done
kowser: but those will be diff
kowser: right?
Sakif Shahriar: =))

By | 2012-07-04T22:19:17+00:00 July 4th, 2012|Design Pattern|1 Comment

About the Author:

2 hand 2 leg 2 ear and 2 eyes... i am a man who is living to live...

One Comment

  1. Samiron July 5, 2012 at 12:07 AM - Reply

    Nice analogy, Great Post.

Leave a Reply