Android App Development #13

+2 Sam Wong · February 13, 2015
Hi, i'm confused by the codes used in the vids:

RelativeLayout buckysLayout = new  RelativeLayout(this);
Button redButton = new Button(this);

What does the "this " keyword mean? What does it really do? 

Post a Reply


Oldest  Newest  Rating
0 Sam Wong · February 13, 2015
Hey thanks for replying i am familiar with inheritance but i'm still confused by your explanation.
Is there an alternative or simpler explanation? 
So far i've only seen the "this"  keyword been used on variables so i'm not really sure what other uses it has.
0 Quick Shark · February 13, 2015
Tell me if I am wrong. So, in the 1st line, we are associating "this" to relative layout? And in the second line, we are associating the context of relative layout with the Button. Basically, Button is inheriting the necessary properties of the RelativeLayout? 
Or the word "this" is a keyword?
0 Nicholas Eason · February 13, 2015
I'm pretty sure that both of the "this" keywords used are in reference to the Activity, or Context.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator