Android之EditText

EditText 可让用户输入文字。常用属性设置: 
layout_width 为 wrap_content 时,EditText的宽度会随着输入的字而变宽。
当为 match_parent 时则会固定为parent 的宽度, 其他设置和 TextView类似。 
另外,可以通过设置android:inputType属性,让 EditText 接受不同的输入数据格式,并且会自动切换到合适的键盘格式。例如:密码(此时会将输入的内容用圆点或者星号来显示)、数字(不可以输入其他字符)等等。 
   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"  时间键盘 
软键盘的Enter键默认显示的是“回车”图标,可以通过设置 android:imeOptions属性来改变不同的图标设置,让用户能直观看到点击 Enter 后可以完成的工作。比如,在一个搜索中,我们输入要搜索的文本,然而按Enter表示要去搜索了,但是默认的Enter键显示的是“完成”图标,不符合搜索的语义,此时就可以通过这个属性来改变其默认设置。这里举几个常用的常量值: 
(1)actionUnspecified 未指定,对应常量 EditorInfo.IME_ACTION_UNSPECIFIED 效果:
(2)actionNone  没有动作,对应常量 EditorInfo.IME_ACTION_NONE 效果: 
(3)actionGo 去往,对应常量 EditorInfo.IME_ACTION_GO  效果: 
(4)actionSearch  搜索,对应常量 EditorInfo.IME_ACTION_SEARCH 效果:   
(5)actionSend  发送,对应常量 EditorInfo.IME_ACTION_SEND 效果: 
(6)actionNext  下一个,对应常量 EditorInfo.IME_ACTION_NEXT 效果: 
(7)actionDone  完成,对应常量 EditorInfo.IME_ACTION_DONE 效果:
posted @ 2016-03-10 19:57  冷的锋刃  阅读(256)  评论(0)    收藏  举报