editView顯示##。##格式 – Android移動開發技術文章_手機開發 Android移動開發教學課程

boolean isValid=<EditText Variable>.getText().toString().matches(\\d{2}\\.\\d{2});
或者
 EditText text = new EditText(this);
    InputFilter[] filters = new InputFilter[1];
    filters[0] = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            if (end > start) {
                String destTxt = dest.toString();
                String resultingTxt = destTxt.substring(0, dstart) + source.subSequence(start, end) + destTxt.substring(dend);
                if (!resultingTxt.matches("^\\d(\\d(\\.\\d{0,2})?)?")) {
                    return "";
                }
            }
        return null;
        }
    };
    text.setFilters(filters);

作者“技術人生”

發佈留言