I was trying to deploy a small android app, where in , i was trying to display "Hello World" to the user .
The lines of code that i applied here in were (a bit from internet resources) :
TextView text = new TextView(this);
text.setText("Hello World, Here");
setContentView(text);
What i fail to understand is : Why is this
key word is required here ? Can't i just create a plain vanilla TextView
object to set the text like this :
TextView text = new TextView();
text.setText("Hello World, Here");
And, what is the purpose of the setContentView
method here ? Does it work like System.out.println
of java ? A bit confused, any help will be appreciated. Thanks .