自分で作ったり提供したりするものは、まず自分自身で使ってみろろということです。自分じゃ使わないものなら人はいくらでも無責任にも無思考にもなれる。そういう投げやりな「サービス」やら「プロダクツ」なんて、だれだってイヤだ。自分が作り手と同時に利用者の立場になれば、ちゃんと使えるレベルのものを提供しようとします。

2012年3月27日火曜日

Android基本入力フォーム

Android世界を挑戦し始めましたので、まずはAndroid基本入力フォームサンプルを作成する。

main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1"
>
    <TableRow>
        <TextView android:text="Name:" />
        <EditText android:id="@+id/name" />
    </TableRow>
    <TableRow>
        <TextView android:text="Address:" />
        <EditText android:id="@+id/addr" />
    </TableRow>
    <Button android:id="@+id/save"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Save"
    />
</TableLayout>

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sqlendia.android.skeleton"
      android:versionCode="1"
      android:versionName="1.0">
    <supports-screens
    android:xlargeScreens="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="false"
    />
    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <activity android:name="LunchList"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

LunchList.java
package com.sqlendia.android.skeleton;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LunchList extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button save=(Button)findViewById(R.id.save);
        save.setOnClickListener(onSave);
    }

    private View.OnClickListener onSave=new View.OnClickListener() {
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "helo 日本語テスト" + r.getName(), 1000).show();  
        }
    };
}

結果画面

0 件のコメント:

コメントを投稿

ホームページ