开发过程中,我们经常使用到EditText控件,并且会根据各种需求设置它的输入类型。设置EditText输入类型主要有两种方法,一种是使用EditText的setInputType()方法,另一种是在布局文件中使用android:inputType属性来设置。
下面将介绍这两种方法:
(1)使用EditText的setInputType()方法设置输入类型:
EditText editText;
//输入类型为没有指定明确的类型的特殊内容类型
editText.setInputType(InputType.TYPE_NULL);
//输入类型为普通文本
editText.setInputType(InputType.TYPE_CLASS_TEXT);
//输入类型为数字文本
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
//输入类型为电话号码
editText.setInputType(InputType.TYPE_CLASS_PHONE);
//输入类型为日期和时间
editText.setInputType(InputType.TYPE_CLASS_DATETIME);
//输入类型为{@link#TYPE_CLASS_DATETIME}的缺省变化值,允许输入日期和时间。
editText.setInputType(InputType.TYPE_DATETIME_VARIATION_NORMAL);
//输入类型为{@link#TYPE_CLASS_DATETIME}的缺省变化值,只允许输入一个日期。
editText.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE);
//输入类型为{@link#TYPE_CLASS_DATETIME}的缺省变化值,只允许输入一个时间。
editText.setInputType(InputType.TYPE_DATETIME_VARIATION_TIME);
//输入类型为决定所给文本整体类的位掩码
editText.setInputType(InputType.TYPE_MASK_CLASS);
//输入类型为提供附加标志位选项的位掩码
editText.setInputType(InputType.TYPE_MASK_FLAGS);
//输入类型为决定基类内容变化的位掩码
editText.setInputType(InputType.TYPE_MASK_VARIATION);
//输入类型为小数数字,允许十进制小数点提供分数值。
editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
//输入类型为数字是带符号的,允许在开头带正号或者负号
editText.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
//输入类型为{@link#TYPE_CLASS_NUMBER}的缺省变化值:为纯普通数字文本
editText.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL);
//输入类型为{@link#TYPE_CLASS_NUMBER}的缺省变化值:为数字密码
editText.setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD);
//输入类型为自动完成文本类型
editText.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
//输入类型为自动纠正文本类型
editText.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
//输入类型为所有字符大写
editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
//输入类型为每句的第一个字符大写
editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
//输入类型为每个单词的第一个字母大写
editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
//输入多行文本
editText.setInputType(InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
//进行输入时,输入法无提示
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
//输入一个短的,可能是非正式的消息,如即时消息或短信。
editText.setInputType(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
//输入长内容,可能是正式的消息内容,比如电子邮件的主体
editText.setInputType(InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
//输入文本以过滤列表等内容
editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
//输入一个电子邮件地址
editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
//输入电子邮件主题行
editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT);
//输入一个密码
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
//输入老式的普通文本
editText.setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL);
//输入人名
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
//输入邮寄地址
editText.setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
//输入语音发音输入文本,如联系人拼音名称字段
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PHONETIC);
//输入URI
editText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
//输入对用户可见的密码
editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
//输入网页表单中的文本
editText.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
//输入网页表单中的邮件地址
editText.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
//输入网页表单中的密码
editText.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
下面是几个简单的例子:
/**
* 第一个例子:对用户可见的密码字段
*/
editText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
/**
* 第二个例子:具有自动大写的多行邮寄地址
*/
editText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS |
InputType.TYPE_TEXT_FLAG_MULTI_LINE);
/**
* 第三个例子:一个时间字段
*/
editText.setInputType(InputType.TYPE_CLASS_DATETIME |
InputType.TYPE_DATETIME_VARIATION_TIME);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
在本文的后续,将会附上Android源码中的InputType.java。
(2)在布局文件中使用android:inputType属性来设置:
//输入类型为没有指定明确的类型的特殊内容类型
android:inputType="none"
//输入类型为普通文本
android:inputType="text"
//输入类型为数字文本
android:inputType="number"
//输入类型为电话号码
android:inputType=”phone”
//输入类型为日期和时间
android:inputType=”datetime”
//输入类型为{@link#TYPE_CLASS_DATETIME}的缺省变化值,只允许输入一个日期。
android:inputType=”date”
//输入类型为{@link#TYPE_CLASS_DATETIME}的缺省变化值,只允许输入一个时间。
android:inputType=”time”
//输入类型为小数数字,允许十进制小数点提供分数值。
android:inputType="numberDecimal"
//输入类型为数字是带符号的,允许在开头带正号或者负号
android:inputType="numberSigned"
//输入类型为数字密码
android:inputType="numberPassword"
//输入类型为自动完成文本类型
android:inputType="textAutoComplete"
//输入类型为自动纠正文本类型
android:inputType="textAutoCorrect"
//输入类型为所有字符大写
android:inputType="textCapCharacters"
//输入类型为每句的第一个字符大写
android:inputType="textCapSentences"
//输入类型为每个单词的第一个字母大写
android:inputType="textCapWords"
//输入法多行文本
android:inputType="textImeMultiLine"
//进行输入时,输入法无提示
android:inputType="textNoSuggestions"
//输入一个短的,可能是非正式的消息,如即时消息或短信。
android:inputType="textShortMessage"
//输入长内容,可能是正式的消息内容,比如电子邮件的主体
android:inputType="textLongMessage"
//输入文本以过滤列表等内容
android:inputType="textFilter"
//输入一个电子邮件地址
android:inputType="textEmailAddress"
//输入电子邮件主题行
android:inputType="textEmailSubject"
//输入一个密码
android:inputType="textPassword"
//输入对用户可见的密码
android:inputType="textVisiblePassword"
//输入人的姓名
android:inputType="textPersonName"
//输入邮寄地址
android:inputType="textPostalAddress"
//输入语音发音输入文本,如联系人拼音名称字段
android:inputType="textPhonetic"
//输入URI
android:inputType="textUri"
//输入网页表单中的文本
android:inputType="textWebEditText"
//输入网页表单中的邮件地址
android:inputType="textWebEmailAddress"
//输入网页表单中的密码
android:inputType="textWebPassword"
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
最后,附上上Android源码中的InputType.java:
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.text;
import android.text.TextUtils;
/**
* Bit definitions for an integer defining the basic content type of text
* held in an {@link Editable} object. Supported classes may be combined
* with variations and flags to indicate desired behaviors.
*
* <h3>Examples</h3>
*
* <dl>
* <dt>A password field with with the password visible to the user:
* <dd>inputType = TYPE_CLASS_TEXT |
* TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
*
* <dt>A multi-line postal address with automatic capitalization:
* <dd>inputType = TYPE_CLASS_TEXT |
* TYPE_TEXT_VARIATION_POSTAL_ADDRESS |
* TYPE_TEXT_FLAG_MULTI_LINE
*
* <dt>A time field:
* <dd>inputType = TYPE_CLASS_DATETIME |
* TYPE_DATETIME_VARIATION_TIME
* </dl>
*/
public interface InputType {
/**
* Mask of bits that determine the overall class
* of text being given. Currently supported classes are:
* {@link #TYPE_CLASS_TEXT}, {@link #TYPE_CLASS_NUMBER},
* {@link #TYPE_CLASS_PHONE}, {@link #TYPE_CLASS_DATETIME}.
* <p>IME authors: If the class is not one you
* understand, assume {@link #TYPE_CLASS_TEXT} with NO variation
* or flags.<p>
*/
public static final int TYPE_MASK_CLASS = 0x0000000f;
<span class="hljs-javadoc">/**
* Mask of bits that determine the variation of
* the base content class.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_MASK_VARIATION = <span class="hljs-number">0x00000ff0</span>;
<span class="hljs-javadoc">/**
* Mask of bits that provide addition bit flags
* of options.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_MASK_FLAGS = <span class="hljs-number">0x00fff000</span>;
<span class="hljs-javadoc">/**
* Special content type for when no explicit type has been specified.
* This should be interpreted to mean that the target input connection
* is not rich, it can not process and show things like candidate text nor
* retrieve the current text, so the input method will need to run in a
* limited "generate key events" mode, if it supports it. Note that some
* input methods may not support it, for example a voice-based input
* method will likely not be able to generate key events even if this
* flag is set.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_NULL = <span class="hljs-number">0x00000000</span>;
<span class="hljs-javadoc">/**
* Class for normal text. This class supports the following flags (only
* one of which should be set):
* {@link #TYPE_TEXT_FLAG_CAP_CHARACTERS},
* {@link #TYPE_TEXT_FLAG_CAP_WORDS}, and.
* {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. It also supports the
* following variations:
* {@link #TYPE_TEXT_VARIATION_NORMAL}, and
* {@link #TYPE_TEXT_VARIATION_URI}. If you do not recognize the
* variation, normal should be assumed.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_CLASS_TEXT = <span class="hljs-number">0x00000001</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize all characters. Overrides
* {@link #TYPE_TEXT_FLAG_CAP_WORDS} and
* {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_CHARACTERS}. Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_CAP_CHARACTERS = <span class="hljs-number">0x00001000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
* every word. Overrides {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This
* value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_WORDS}. Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_CAP_WORDS = <span class="hljs-number">0x00002000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
* each sentence. This value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_SENTENCES}. For example
* in English it means to capitalize after a period and a space (note that other
* languages may have different characters for period, or not use spaces,
* or use different grammatical rules). Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_CAP_SENTENCES = <span class="hljs-number">0x00004000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: the user is entering free-form
* text that should have auto-correction applied to it. Without this flag,
* the IME will not try to correct typos. You should always set this flag
* unless you really expect users to type non-words in this field, for
* example to choose a name for a character in a game.
* Contrast this with {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE} and
* {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
* {@code TYPE_TEXT_FLAG_AUTO_CORRECT} means that the IME will try to
* auto-correct typos as the user is typing, but does not define whether
* the IME offers an interface to show suggestions.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_AUTO_CORRECT = <span class="hljs-number">0x00008000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: the text editor (which means
* the application) is performing auto-completion of the text being entered
* based on its own semantics, which it will present to the user as they type.
* This generally means that the input method should not be showing
* candidates itself, but can expect the editor to supply its own
* completions/candidates from
* {@link android.view.inputmethod.InputMethodSession#displayCompletions
* InputMethodSession.displayCompletions()} as a result of the editor calling
* {@link android.view.inputmethod.InputMethodManager#displayCompletions
* InputMethodManager.displayCompletions()}.
* Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
* {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
* {@code TYPE_TEXT_FLAG_AUTO_COMPLETE} means the editor should show an
* interface for displaying suggestions, but instead of supplying its own
* it will rely on the Editor to pass completions/corrections.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_AUTO_COMPLETE = <span class="hljs-number">0x00010000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: multiple lines of text can be
* entered into the field. If this flag is not set, the text field
* will be constrained to a single line. The IME may also choose not to
* display an enter key when this flag is not set, as there should be no
* need to create new lines.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_MULTI_LINE = <span class="hljs-number">0x00020000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: the regular text view associated
* with this should not be multi-line, but when a fullscreen input method
* is providing text it should use multiple lines if it can.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_IME_MULTI_LINE = <span class="hljs-number">0x00040000</span>;
<span class="hljs-javadoc">/**
* Flag for {@link #TYPE_CLASS_TEXT}: the input method does not need to
* display any dictionary-based candidates. This is useful for text views that
* do not contain words from the language and do not benefit from any
* dictionary-based completions or corrections. It overrides the
* {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} value when set.
* Please avoid using this unless you are certain this is what you want.
* Many input methods need suggestions to work well, for example the ones
* based on gesture typing. Consider clearing
* {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} instead if you just do not
* want the IME to correct typos.
* Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
* {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE}:
* {@code TYPE_TEXT_FLAG_NO_SUGGESTIONS} means the IME should never
* show an interface to display suggestions. Most IMEs will also take this to
* mean they should not try to auto-correct what the user is typing.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_FLAG_NO_SUGGESTIONS = <span class="hljs-number">0x00080000</span>;
<span class="hljs-javadoc">/**
* Default variation of {@link #TYPE_CLASS_TEXT}: plain old normal text.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_NORMAL = <span class="hljs-number">0x00000000</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a URI.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_URI = <span class="hljs-number">0x00000010</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering an e-mail address.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_EMAIL_ADDRESS = <span class="hljs-number">0x00000020</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the subject line of
* an e-mail.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_EMAIL_SUBJECT = <span class="hljs-number">0x00000030</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a short, possibly informal
* message such as an instant message or a text message.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_SHORT_MESSAGE = <span class="hljs-number">0x00000040</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the content of a long, possibly
* formal message such as the body of an e-mail.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_LONG_MESSAGE = <span class="hljs-number">0x00000050</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the name of a person.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_PERSON_NAME = <span class="hljs-number">0x00000060</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a postal mailing address.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_POSTAL_ADDRESS = <span class="hljs-number">0x00000070</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a password.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_PASSWORD = <span class="hljs-number">0x00000080</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a password, which should
* be visible to the user.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = <span class="hljs-number">0x00000090</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text inside of a web form.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_WEB_EDIT_TEXT = <span class="hljs-number">0x000000a0</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text to filter contents
* of a list etc.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_FILTER = <span class="hljs-number">0x000000b0</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text for phonetic
* pronunciation, such as a phonetic name field in contacts. This is mostly
* useful for languages where one spelling may have several phonetic
* readings, like Japanese.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_PHONETIC = <span class="hljs-number">0x000000c0</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering e-mail address inside
* of a web form. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be seen as {@link #TYPE_TEXT_VARIATION_EMAIL_ADDRESS}
* when passed through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS = <span class="hljs-number">0x000000d0</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering password inside
* of a web form. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be seen as {@link #TYPE_TEXT_VARIATION_PASSWORD}
* when passed through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_TEXT_VARIATION_WEB_PASSWORD = <span class="hljs-number">0x000000e0</span>;
<span class="hljs-javadoc">/**
* Class for numeric text. This class supports the following flags:
* {@link #TYPE_NUMBER_FLAG_SIGNED} and
* {@link #TYPE_NUMBER_FLAG_DECIMAL}. It also supports the following
* variations: {@link #TYPE_NUMBER_VARIATION_NORMAL} and
* {@link #TYPE_NUMBER_VARIATION_PASSWORD}.
* <p>IME authors: If you do not recognize
* the variation, normal should be assumed.</p>
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_CLASS_NUMBER = <span class="hljs-number">0x00000002</span>;
<span class="hljs-javadoc">/**
* Flag of {@link #TYPE_CLASS_NUMBER}: the number is signed, allowing
* a positive or negative sign at the start.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_NUMBER_FLAG_SIGNED = <span class="hljs-number">0x00001000</span>;
<span class="hljs-javadoc">/**
* Flag of {@link #TYPE_CLASS_NUMBER}: the number is decimal, allowing
* a decimal point to provide fractional values.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_NUMBER_FLAG_DECIMAL = <span class="hljs-number">0x00002000</span>;
<span class="hljs-javadoc">/**
* Default variation of {@link #TYPE_CLASS_NUMBER}: plain normal
* numeric text. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be dropped when passed through
* {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_NUMBER_VARIATION_NORMAL = <span class="hljs-number">0x00000000</span>;
<span class="hljs-javadoc">/**
* Variation of {@link #TYPE_CLASS_NUMBER}: entering a numeric password.
* This was added in {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An
* IME must target this API version or later to see this input type; if it
* doesn't, a request for this type will be dropped when passed
* through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_NUMBER_VARIATION_PASSWORD = <span class="hljs-number">0x00000010</span>;
<span class="hljs-javadoc">/**
* Class for a phone number. This class currently supports no variations
* or flags.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_CLASS_PHONE = <span class="hljs-number">0x00000003</span>;
<span class="hljs-javadoc">/**
* Class for dates and times. It supports the
* following variations:
* {@link #TYPE_DATETIME_VARIATION_NORMAL}
* {@link #TYPE_DATETIME_VARIATION_DATE}, and
* {@link #TYPE_DATETIME_VARIATION_TIME}.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_CLASS_DATETIME = <span class="hljs-number">0x00000004</span>;
<span class="hljs-javadoc">/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* both a date and time.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_DATETIME_VARIATION_NORMAL = <span class="hljs-number">0x00000000</span>;
<span class="hljs-javadoc">/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* only a date.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_DATETIME_VARIATION_DATE = <span class="hljs-number">0x00000010</span>;
<span class="hljs-javadoc">/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* only a time.
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> TYPE_DATETIME_VARIATION_TIME = <span class="hljs-number">0x00000020</span>;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
(function () {('pre.prettyprint code').each(function () {
var lines = (this).text().split(′\n′).length;var numbering = $('
(this).addClass(′has−numbering′).parent().append( numbering);
for (i = 1; i <= lines; i++) {
numbering.append( ('
- ').text(i));
};
$numbering.fadeIn(1700);
});
});