1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > android:inputType 类型详细介绍

android:inputType 类型详细介绍

时间:2021-02-09 05:04:37

相关推荐

android:inputType 类型详细介绍

android:inputType 类型详细介绍

//文本类型,多为大写、小写和数字符号。

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”//URI格式

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”//时间键盘

当然也可以单独设置android:digits=""来控制输入的字符

顺便补充下键盘右下角的键设置

actionUnspecified未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED效果:

actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE效果:

actionGo去往,对应常量EditorInfo.IME_ACTION_GO 效果:

actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH效果:

actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND效果:

actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT效果:

actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE效果:

android:imeOptions=”flagNoExtractUi” //使软键盘不全屏显示,只占用一部分屏幕 同时,

这个属性还能控件软键盘右下角按键的显示内容,默认情况下为回车键

android:imeOptions=”actionNone” //输入框右侧不带任何提示

android:imeOptions=”actionGo” //右下角按键内容为’开始’

android:imeOptions=”actionSearch” //右下角按键为放大镜图片,搜索

android:imeOptions=”actionSend” //右下角按键内容为’发送’

android:imeOptions=”actionNext” //右下角按键内容为’下一步’ 或者下一项

android:imeOptions=”actionDone” //右下角按键内容为’完成’

注意:如果设置了 键盘没有变化 那么需要单独加一些其他的属性 配合使用,一般添加android:inputType="text"就行了

xml中 属性设置:

1 将singleLine设置为true

2 将inputType设置为text

java代码设置

editText.setInputType(EditorInfo.TYPE_CLASS_TEXT);

editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH)

键盘的监听

1、设置监听 editText.setOnEditorActionListener(this);

2、重写onEditorAction

@Override

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

if (actionId == EditorInfo.IME_ACTION_SEARCH) {

//

}

return false;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。