Android Document: How To Create A New Project?
Android Document: How To Create A New Project?
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
int the above line we are extending the Hello class from Activity class. An Activity is the place
where a user can add the view.
Public void onCreate(...) is a call back function that must be overridden by the derived class of
class Activity.
TextView tv = new TextView(this);
tv.setText("Hello Android, Learning Android is a great fun.");
setContentView(tv);
In the above three lines, we are creating an object of TextView and set the text “Hello Android,
Learning Android is a great fun.” to the TextView. And in the last line we are setting the
Content View as a TextView.
Declaring Layout
Your layout is the architecture for the user interface in an Activity. It defines the layout
structure and holds all the elements that appear to the user. You can declare your layout in two
ways:
You should load the layout resource from your application code, in your activity.onCreate()
callback implementation.