Yeah, the concept of "this" is fundamental to object-oriented
programming, and pretty much all OO languages will have something
similar.  It means the object whose instance method is currently
executing.  It's called "this" in Java and C++, "self" in Objective C,
and probably a few other terms in other OO languages.  In general, if
you have an instance variable named "x" in your class, you can
interchangeably refer to it as "x" or "this.x", the latter form being
handy if you happened to name a parameter or local variable the same
name.  "this" is also used (as in your example) to pass a reference to
the current object to other methods.

Another concept is "super", referring to instance variables and
methods in the super-class of the current class.

You'd be well-advised to study enough Java to fully comprehend these
concepts before you attempt to do Android programming.  Otherwise
you'll be stumbling around in the dark.

On May 15, 5:33 am, tyliong <[email protected]> wrote:
> Hi,
>
> I am a newbie developer and have done iphone coding. I just don't
> understand how some code works as it is not explained in my book.
>
> Toast.makeText(this, "Please enter a valid
> number",Toast.LENGTH_LONG).show()
>
> what is "this" in the brackets
> makeText("this",...)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to