Android input method problem solved the problem of Samsung s5830i or Huawei low-end machine input method crash

Source: Internet
Author: User

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.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.