天天看點

Android設定EditText隻能輸入數字,不包含小數點

1、XML檔案中通過

android:digits="0123456789"隻能輸入整數

2、在代碼中沒有setDigits屬性,我們可以通過

<span style="background-color: rgb(0, 204, 204);">et_reason.setRawInputType(InputType.TYPE_CLASS_NUMBER);
et_reason.setKeyListener(DigitsKeyListener.getInstance("0123456789"));</span>