Android imeOptions usage and precautions
In android development, it is essential to use the text box (EditText) for data input, which requires some control over the input method.
Android: inputType: Specifies the input method type. It can be an int type. | select multiple input methods. For the value, see the android. text. InputType class.
Optional values include text, textUri, phone, number, and so on.
Android: imeOptions: Specifies the Input key function in the window. The optional values are normal, actionUnspecified, actionNone, actionGo, actionSearch, actionSend, actionNext, and actionDone.
Some input methods may not support this well.
[Html]
- The following LAYOUT definition file provides some examples to illustrate the use of inputType and imeOptions.
-
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Normal text
-
- Android: inputType = text
-
- Android: imeOptions = actionNext
- />
-
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Integer only
-
- Android: inputType = number
-
- Android: imeOptions = actionNext
- />
-
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Decimal only
-
- Android: inputType = numberDecimal
-
- Android: imeOptions = actionNext
- />
-
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Phone number
-
- Android: inputType = phone
-
- Android: imeOptions = actionNext
- />
-
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Email
-
- Android: inputType = textEmailAddress
-
- Android: imeOptions = actionSend
- />
- Android: layout_width = fill_parent android: layout_height = wrap_content
-
- Android: hint = Web Site
-
- Android: inputType = textUri
-
- Android: imeOptions = actionDone/>
- With inputType, the keyboard of the Input Method automatically changes. When inputType = number, English characters are not allowed.
- Note: android: phoneNumber, android: numeric, these attributes have been deprecated and many input methods are no longer supported. It is better to use inputType directly. In addition, it is best to use Google pinyin or android keyboard for such debugging. Otherwise, imeOptions may not be displayed normally. For example, Baidu input method does not support imeOptions until I delete it.