Android input method problem solved the problem of Samsung s5830i or Huawei low-end machine input method crash
In EditText, set the property android: inputType = "numberDecimal". In some SamSung mobile phones (s5830i), this causes the native Input Method to crash. if the property is set to android: inputType = "number", the system will not crash. in the past, these input methods do not support floating-point numbers. They only support integers.
TextEdit settings listener
Filter empty strings, non-floating-point numbers, starting with 0 (for example, 0123.11)
String regEx = "^ [0-9] + \\. {0, 1} [0-9] {0, 2} $ "; // The regular expression can only be a floating point, followed by two small numbers.
priceEt.addTextChangedListener(new TextWatcher() {@Overridepublic void onTextChanged(CharSequence s, int start, int before,int count) {if (s != null) {if (".".equals(txt_amount.getText().toString().trim()) || !(Pattern.matches(regEx, txt_amount.getText() .toString().trim()))) { String str = txt_amount.getText().toString().trim(); if (txt_amount.getText().toString().length() >= 1) { txt_amount.setText(str.substring(0, txt_amount.getText() .toString().length() - 1)); txt_amount.setSelection(txt_amount.getText().toString() .length()); } }}}@Overridepublic void beforeTextChanged(CharSequence s, int start, int count,int after) {}@Overridepublic void afterTextChanged(Editable s) {}});
Pay attention to a property in xml: android: digits = "0123456789 ."
Dights limit can only be 0 ~ 9 and '.' data types. Other formats are not supported.
After completing the above two steps, you can implement custom floating point data. The numberDecimal type that calls the api will not appear on the low-end server. The input method reports an error.