我需要 EditText 只允许七个整数和两个十进制数。例如:7777777.99
我在 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;
}
}
});