private String cacleTotal(String number, String price) { if (!ValidateUtil.isNumeric(number)) { return null; } else if (!ValidateUtil.isDecimal(price)) { return null; } int numInt = Integer.parseInt(number); double priceDb = Double.parseDouble(price); return String.valueOf(numInt * priceDb); }
private boolean checkForm() { String productNumberStr = productNumber.getText().toString(); String productPriceTextStr = productPriceText.getText().toString(); boolean isFlag = true; if (!ValidateUtil.isNumeric(productNumberStr)) { numberTextInputLayout.setError("请输入整数!"); isFlag = false; } else { numberTextInputLayout.setErrorEnabled(false); } if (!ValidateUtil.isDecimal(productPriceTextStr)) { priceTextInputLayout.setError("请输入小数 xx.xx!"); isFlag = false; } else { priceTextInputLayout.setErrorEnabled(false); } return isFlag; }