gpt4 book ai didi

android - PhoneNumberFormattingTextWatcher 在 android MotoG 编辑文本中不起作用

转载 作者:行者123 更新时间:2023-11-29 14:21:34 34 4
gpt4 key购买 nike

在 android phonenumberformattingtext 中,watcher 不适用于 Moto-G Mobile,但它在(nexus -7、nexus-9、nexus-6、nexus-4)中工作正常,但它不是在 Moto -G 工作请帮忙。

我的代码是:

phoneNumber.addTextChangedListener(this);
phoneNumber.setFilters(new InputFilter[] { filter , new InputFilter.LengthFilter(14)});
alternativePhoneNumber.setFilters(new InputFilter[] { filter , new InputFilter.LengthFilter(14)});
phoneNumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
alternativePhoneNumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

最佳答案

来晚了,但这肯定对 future 的观众有帮助。

mPhoneText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

这在 21 或更高版本的 api 中不起作用。所以你应该像这样包装在 api lvl 条件中。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mPhoneText.addTextChangedListener(new PhoneNumberFormattingTextWatcher("US"));
}else {
mPhoneText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}

不要忘记设置 inputType="phone"

我在 moto g4 plus 上测试过。

关于android - PhoneNumberFormattingTextWatcher 在 android MotoG 编辑文本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30501891/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com