IN the famous hello world tutorial below, I want to ask about a few things:
here are my questions:
1-Is tv a variable or what is that?
2-what is "this" in TextView(this)? What does it represent? What does it do?
3-when you say tv.setText("Hello, Android"), what does tv.setText mean? I know setText is a command but what why do we have tv. in front of it?
4-Is setContentView a command? The tv in paranthesis there... is it a variable or what does it do? is it coming from TextView tv, or tv.setText?
Please answer one by one to each question, as I asked it the way I will understand sorry I am just a beginner...
Code:
package com.mysite.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MysitehelloworldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
here are my questions:
1-Is tv a variable or what is that?
2-what is "this" in TextView(this)? What does it represent? What does it do?
3-when you say tv.setText("Hello, Android"), what does tv.setText mean? I know setText is a command but what why do we have tv. in front of it?
4-Is setContentView a command? The tv in paranthesis there... is it a variable or what does it do? is it coming from TextView tv, or tv.setText?
Please answer one by one to each question, as I asked it the way I will understand sorry I am just a beginner...