Android : Activity and View Understanding

What are Activity and View in Android:
Dissecting - Activity and View

FirstSee this example:

package com.mytest;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        TextView textView = new TextView(this); // Construct a TextView UI
        textView.setText("Hello, world!");      // Set text for TextView
        setContentView(textView);               // This Activity sets content to the TextView
An application could have one or more Activity. An Activity is a single, focused thing that the user can do. Our Android Java class HelloAndroid extends from the Activityclass, and overrides the onCreate() method. The onCreate() is a call-back method, which will be called by the Android System when the activity is first created.
View is a drawable object (or UI component). We construct a TextView (which is a subclass of View), and set it to contain the String "Hello, world". We then set the Activity screen to this TextView.

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...