Android ime problem solved Samsung s5830i or Huawei Low-end machine Input method crash problem

Source: Internet
Author: User

setting properties in EditText android:inputtype= "Numberdecimal" in some Samsung phones (s5830i) causes its native input method to crash. If you set the property to Android:inputtype= " Number "will not crash. Originally these input method calls do not support floating-point numbers, only can support integers.

TextEdit Setting monitoring

Filter empty strings, non-floating-point numbers, starting with 0 (for example, 0123.11)

String regEx = "^[0-9]+\\." {0,1} [0-9] {0,2}$ ";//Regular expression input can only be floating-point number, followed by 2 decimal digits

<span style= "FONT-SIZE:14PX;" >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.gett                Ext (). 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) {}}); </span> 

Note An attribute in XML: android:digits= "0123456789."
Dights limit only input 0~9 and '. ' These data types, other formats do not support

<span style= "FONT-SIZE:14PX;" ><edittext                            android:id= "@+id/money"                            android:layout_width= "fill_parent"                            android:layout_height= "60DP"                            android:background= "@null"                            android:singleline= "true"                            android:digits= "0123456789."                            android:imeoptions= "Actionnext"                            android:maxlength= "7"/></span>


Complete the above two steps, you can implement the custom floating point data, the low-end machine will not appear to call the API Numberdecimal type, input method error.




Android Input Method problem solved Samsung s5830i or Huawei Low-end machine input crash problem

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.