You are initializing textview
TextView myText = (TextView) findViewById(R.id.myText);
// the one in the braces is casting to textview
public final View findViewById (int id)
You can findViewById of the current view hierarchy set to the activity.
Look for a child view with the given id. If this view has the given id, return this view.
If you want to do it programatically
TextView myText = new TextView(ActivityName.this);
If you do as above you need to add it to the root view
If you have LinearLayout as root view
setContenView(R.layout.mylayout);
LinearLayout ll = (LinearLayout) findViewById(R.id.linearlayout);
ll.addView(myText);
or
setContentView(myText);