setOnClickListener actually takes the callback method that will be
invoked when the user presses the button interface as an argument, so
it doesn't take a view....  Basically you're saying "this" is just a
reference to the current object you're in.  So if you're in a specific
method and you use this, it tells the complier to pass in class
variables not the local ones because the instance of the class would
be outside of the method??  also, if your class contains multiple
instances how does the complier know which one "this" is referring
too?

On Jul 13, 1:47 am, Justin Anderson <[email protected]> wrote:
> *> I know that the keyword "this" refers to an instance variable or can
> invoke a constructor*
> That is not what the keyword "this" references.  It references the instance
> of the class you are currently in...
>
> *> but I don't understand how passing "this" as the arg for
> setOnClickListener () works?Could someone explain?*
> Take a look at the argument list for setOnClickListener...  One of the
> arguments is probably a View.  So, when you are calling setOnClickListener
> and you are in a class that inherits View, you pass "this" because "this"
> is-a View instance.  It wouldn't work if you were calling setOnClickListener
> from a class that didn't eventually inherit from View.
>
> Hope that helps... sounds to me like you may want to brush up a little bit
> on Java.
>
> ----------------------------------------------------------------------
> There are only 10 types of people in the world...
> Those who know binary and those who don't.
> ----------------------------------------------------------------------
>
>
>
> On Mon, Jul 12, 2010 at 8:50 PM, Keith Roberts <[email protected]> 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
>
> > --
> > 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]<android-beginners%2Bunsubscr 
> > [email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-beginners?hl=en

-- 
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

Reply via email to