このエントリーをはてなブックマークに追加
>> 開発>> APIサンプル

App - Activity - Hello World

Hello World

XMLでレイアウト指定してます。

Java

java部分ではxmlレイアウトを指定します

public class HelloWorld extends Activity
{
    /**
     * Initialization of the Activity after it is first created.  Must at least
     * call {@link android.app.Activity#setContentView setContentView()} to
     * describe what is to be displayed in the screen.
     */
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // Be sure to call the super class.
        super.onCreate(savedInstanceState);

        // See assets/res/any/layout/hello_world.xml for this
        // view layout definition, which is being set here as
        // the content of our screen.

        setContentView(R.layout.hello_world);
    }
}

Layout

<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    android:text="@string/hello_world"/>
</pre>

関連サイト
www.akjava.com | github.com/akjava
Copyright (C) 2008-20014 Aki Miyazakion Google+ All Rights Reserved.