【Android开发API】用户界面-文本区域 - Text Fields.pdf
文本预览下载声明
eoe 移动开发者社区
负责⼈:Monica
主任务原文链接:/guide/topics/ui/controls/text.html
A text field allows the user to type text into your app. It can be either single line or multi-line. Touching a text
field places the cursor and automatically displays the eyboard. In addition to typing, text fields allow for a
variety of other activities, such as text selection (cut, copy, paste) and data loo -up via auto-completion.
文本框允许用户在应用程序中输⼊文本 。它们可以是单 的,也可以是多 的。点击文本框后显示光标,并 自动
显示键盘 。除了输⼊,文本框还包含其它操作,比如文本选择 (剪切,复制,粘贴)以及数据的自动查找功能 。
You can add a text field to you layout with the EditText object. You should usually do so in your XML layout
with a element.
你可以使用EditText对象在布局中添加⼀个文本字段, android里的写法通常是在XML布局文件中添加元素
/images/ui/edittext-noextract.png
Specifying the Keyboard Type-指指定定键键盘盘类类型型
Text fields can have different input types, such as number, date, password, or email address. The type
determines what ind of characters are allowed inside the field, and may prompt the virtual eyboard to
optimize its layout for frequently used characters.
文本字段可以有不同的输⼊类型,如数字,日期,密码,或电⼦邮件地址 。类型确定文本框内允许输⼊什么样的
字符,可能会提示虚拟键盘调整其布局来显示最常用的字符 。
You can specify the type of eyboard you want for your EditText object with the android :inputType attribute.
For example, if you want the user to input an email address, you should use the textEmailAddress input type:
你可以在EditText对象使用Android :inputType属性指定输⼊类型的键盘,例如:你想输⼊⼀个电⼦邮件地址上的
用户,inputType属性应为textEmailAddress:
/images/ui/edittext-text.png
图1:默认的文字输⼊类型 。
There are several different input types available for different situations. You can find them all listed with the
documentation for android :inputType
针对不同的情况有⼏种不同的输⼊类型 。你可以找到所有的文件中列出的android :inputType属性
/images/ui/edittext-email.png
1/5
显示全部