Hello World

Visualizza il testo "Hello Android World" al centro dello schermo del nostro terminale.

java

package com.app.helloworld;
 
import android.app.Activity;
import android.os.Bundle;
 
public class helloworld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // Visualizza il layout come descritto nel file main.xml
 
    }
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textSize="21sp"
    android:layout_gravity="center_horizontal"
    android:gravity="center_horizontal"
    android:text="Hello Android World">
</TextView>
</LinearLayout>