我需要的EditText允許只有七個整數和兩個小數。例如:7777777.99只允許兩位小數輸入EDITTEXT
我嘗試用這個表達式,在onTouchListener事件,但沒有工作。順便說一下,這是正確的事件呢?
txtRespNumero.addTextChangedListener(new TextWatcher() {
int count = 0; // Declare as Instance Variable
boolean isSeven = true; // Declare as Instance Variable
public void onTextChanged(CharSequence s, int start, int before,
int count) {
count++;
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void afterTextChanged(Editable s) {
if(isSeven){
if(count == 7){
s.append(".");
isSeven = true;
}
}
if(count < 7){
isSeven = true;
}
}
});
我嘗試用這種解決方案,但應用程序是錯誤和關閉時,輸入的第一個數字......看到問題更新最多... – ale