I am new to Java, but since Justin says that the this reference is
essentially the same as in C++ and C# I hope my comments are helpful.
I think one point that was not made clear is that the operating system
(Android, Linux or whatever) is not written in Java but if it was
written in Java it would need to call event handlers in a manner that is
independent of the language. So when Android calls the
setOnClickListener event handler, it does not have a this reference and
could not call the event handler with this even if it knew what this is.
So it is quite common to pass the this as an argument so the event
handler can access the other members of it's class.
Keith Roberts wrote:
Hey all,
I know that the keyword "this" refers to an instance variable or can
invoke a constructor, but I don't understand how passing "this" as the
arg for setOnClickListener () works?Could someone explain?
Thanks,
keith
--
Sam Hobbs
Los Angeles, CA
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en