0

我将 maxlengnth 用于编辑文本,我将其设置为 7,尽管它允许输入 6 个字符。它只允许 6 个字符,而不是 7 个......

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

        <requestFocus />
    </EditText>

爪哇代码

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

字符限制的最佳和最简单的工作方式是什么?

4

1 回答 1

1

经过快速搜索和少量测试后,我发现了以下内容

只需删除

txt_phonenumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

这条线。为什么因为The formatting is based on the current system locale and future locale changes may not take effect on this instance。有关更多详细信息,请参见此处。删除此行后,您可以输入 7 位数字。

我希望这会对你有所帮助。

于 2013-05-28T11:31:13.903 回答