標籤:限制只輸入某些值 數字和字母 android edittext輸入數字和字母 edittext輸入字母
限制只輸入某些值包括數字、字母等
android:digits="0123456789abcdefghigklmnopqrstuvwxyz"
上面這行代碼可以是你任何的限制,只能輸入什麼就到裡面寫就可以了,上面寫的是只可以輸入數字和字母。
android:inputType="textPassword"android:digits="0123456789abcdefghigklmnopqrstuvwxyz"
這裡是只能輸入數字和字母並且是密碼格式,這兩個設定並沒有衝突,android:inputType="textPassword"這裡是文本,是可以輸入中文的,但是要是你加了android:digits="0123456789abcdefghigklmnopqrstuvwxyz",inputType這裡的中文就會失效了,但是password不會失效,這裡只是打個比方,大家都懂的。
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" IME多行(如果支援) android:inputType="textNoSuggestions" 不提示 android:inputType="textUri" 網址 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 限制只輸入某些值包括數字、字母等