문제

I use maxlengnth for edittext, I set it 7 altough it allows to input 6 characters. It only allow 6 caharcters, instead of 7...

    <EditText
        android:id="@+id/editText1"
        style="@style/txtstyle"
        android:layout_weight="5"
        android:inputType="number"
        android:maxLength="7" >

        <requestFocus />
    </EditText>

java code

txt_phonenumber = (EditText) findViewById(R.id.editText1);
txt_phonenumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

What is the best and simplest working way for character limit?

도움이 되었습니까?

해결책

After quick search and little testing I found the following

just remove

txt_phonenumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

this line. Why because The formatting is based on the current system locale and future locale changes may not take effect on this instance. For more detail see here. After removing this line you can enter 7 digits.

I hope this wil help you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top