Android中inputType属性在EditText输入值时启动的虚拟键盘的风格有着重要的作用。这也大大的方便的操作。有时需要虚拟键盘只为字符或只为数字。所以inputType尤为重要。
设置文本的类型,用于帮助输入法显示合适的键盘类型。
有如下值设置:
none、text、
textCapCharacters字母大小、
textCapWords单词首字母大小、
textCapSentences仅第一个字母大小、
textAutoCorrect、
textAutoComplete自动完成、
textMultiLine多行输入、
textImeMultiLine输入法多行(如果支持)、
textNoSuggestions不提示、
textEmailAddress电子邮件地址、
textEmailSubject邮件主题、
textShortMessage短信息(会多一个表情按钮出来,点开如下图)、
textLongMessage长讯息?、
textPersonName人名、
textPostalAddress地址、
textPassword密码、
textVisiblePassword可见密码(实现禁止输入中文)、
textWebEditText作为网页表单的文本、
textFilte文本筛选过滤、
textPhonetic拼音输入、
numberSigned有符号数字格式、
numberDecimal可带小数点的浮点格式、
phone电话号码、
datetime时间日期、
date日期、
time时间
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="phone" />
//文本类型,多为大写、小写和数字符号。
android:inputType="none"
android:inputType="text"
android:inputType="textCapCharacters"
android:inputType="textCapWords"
android:inputType="textCapSentences"
android:inputType="textAutoCorrect"
android:inputType="textAutoComplete"
android:inputType="textMultiLine"
android:inputType="textImeMultiLine"
android:inputType="textNoSuggestions"
android:inputType="textUri"
android:inputType="textEmailAddress"
android:inputType="textEmailSubject"
android:inputType="textShortMessage"
android:inputType="textLongMessage"
android:inputType="textPersonName"
android:inputType="textPostalAddress"
android:inputType="textPassword"
android:inputType="textVisiblePassword"
android:inputType="textWebEditText"
android:inputType="textFilter"
android:inputType="textPhonetic"
//数值类型
android:inputType="number"
android:inputType="numberSigned"
android:inputType="numberDecimal"
android:inputType="phone"//拨号键盘
android:inputType="datetime"
android:inputType="date"//日期键盘
android:inputType="time"//时间键盘