zoukankan      html  css  js  c++  java
  • Android EditText输入格式设置

    在开发的过程中,通常会用到EditText,如何让虚拟键盘来适应输入框中内容的类型,通常我们都会在xml文件中加入android:inputType=""。
    android:inputType="none"android:inputType="text"android:inputType="textCapCharacters"//前3个输入普通字符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"//时间键盘
    1、输入法Enter键图标的设置:
    软件盘的界面替换只有一个属性android:imeOptions,这个属性的可以取的值有normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone,例如当值为actionNext时enter键外观变成一个向下箭头,而值为actionDone时enter键外观则变成了“完成”两个字。
    我们也可以重写enter的事件
     
    软键盘的Enter键默认显示的是“完成”文本,通过设置android:imeOptions来改变默认的“完成”文本。这里举几个常用的常量值:
    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 
     
    (EditorInfo.inputType & EditorInfo.TYPE_CLASS_MASK)可以是许多不同的值,包括:
    TYPE_CLASS_NUMBER
    TYPE_CLASS_DATETIME
    TYPE_CLASS_PHONE
    TYPE_CLASS_TEXT
  • 相关阅读:
    js之数组的方法
    js之选项卡
    js之数据类型的比较
    Android sharedUserId研究记录
    直接拿来用!最火的Android开源项目(一)
    [转]简约而不简单——Android SimpleAdapter
    [转]Android GC机制及一些调试信息
    sendToTarget 和 sendMessage 区别
    Android中内容观察者的使用---- ContentObserver类详解 (转)
    Inflate()
  • 原文地址:https://www.cnblogs.com/nimorl/p/6249123.html
Copyright © 2011-2022 走看看