我从这里解除了数字过滤器,
但它不是我需要的,它不允许输入单个小数点,
此过滤器如下所示
DocumentFilter numericFilter = new DocumentFilter(){
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset,
String string, AttributeSet attr)
throws BadLocationException {
fb.insertString(offset, string.replaceAll("[^\\d]", ""), attr);
}
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length,
String text, AttributeSet attrs)
throws BadLocationException {
fb.replace(offset, length, text.replaceAll("[^\\d]", ""), attrs);
}
};
如何改变这一点以便允许单个包含小数点?
感谢,
菲尔