Androidアプリ入門 No.10 EditTextの入力補助関連
今風に書き直した記事がありますので、合わせて参照ください。
blog.webarata3.link
EditText
入力補助関連
ここでは入力補助関連の属性を確認する。
属性 | 説明 |
---|---|
hint | 入力前に入力のヒントとして表示する文字列。 |
textColorHighlight | テキストを選択したときの選択部分の背景色。 |
maxLength | 入力できる文字数。 |
具体的な例は以下。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" android:background="#fff" > <LinearLayout style="@style/commonLayout" > <TextView style="@style/commonLabel" android:text="hint" /> <EditText style="@style/common" android:hint="input!!" /> </LinearLayout> <LinearLayout style="@style/commonLayout" > <TextView style="@style/commonLabel" android:text="textColorHighlight" /> <EditText style="@style/common" android:textColorHighlight="#ff0" /> </LinearLayout> <LinearLayout style="@style/commonLayout" > <TextView style="@style/commonLabel" android:text="maxLength=3" /> <EditText style="@style/common" android:maxLength="3" /> </LinearLayout> </LinearLayout>