liguofeng29’s blog

個人勉強用ブログだっす。

AndroidのUI - EditText

editText.xml
 
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">

<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Account"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input Account name"
android:selectAllOnFocus="true"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Password"/>
<!-- 数字のみパスワード -->
<!-- フォーカス時すべて選択される -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberPassword"
android:selectAllOnFocus="true"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Age"/>
<!-- 数字のみ入力 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Birthday"/>
<!-- 日付のみ入力 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="date" />
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Phone"/>
<!-- 電話番号入力 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:selectAllOnFocus="true"
android:inputType="phone" />
</TableRow>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Register" />
</TableLayout>