Text.TextObserverpublic class PhoneNumberFormattingTextObserver extends Object implements Text.TextObserver
If a new character is detected, the phone number will be formatted based on the country/region code.
| 构造器 | 说明 |
|---|---|
PhoneNumberFormattingTextObserver(String countryCode) |
A constructor used to create a
PhoneNumberFormattingTextObserver instance for observing phone
number changes of the text component. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
getPhoneNumberAfterFormat() |
Obtains the phone number after being formatted.
|
void |
onTextUpdated(String phoneNumber,
int start,
int before,
int count) |
Called back when the text is changed.
|
public PhoneNumberFormattingTextObserver(String countryCode)
PhoneNumberFormattingTextObserver instance for observing phone
number changes of the text component.countryCode - Indicates a two-digit country/region code defined in ISO 3166-1.public void onTextUpdated(String phoneNumber, int start, int before, int count)
Text.TextObserverThis method is used to process the changed text, for example, to verify the input LOV
to get LOVE, for which text is LOVE, start is 3, before is 3,
and count is 1.
onTextUpdated 在接口中 Text.TextObserverphoneNumber - Indicates the current text.start - Indicates the start position of the text to be added.before - Indicates the length of the old text.count - Indicates the length of the text to be added.public String getPhoneNumberAfterFormat()