Most visited

Recently visited

Added in API level 1

PhoneNumberFormattingTextWatcher

public class PhoneNumberFormattingTextWatcher
extends Object implements TextWatcher

java.lang.Object
   ↳ android.telephony.PhoneNumberFormattingTextWatcher


手表 TextView ,如果输入电话号码将格式化。

当用户停止格式化

一旦文本被清除,格式化将重新开始。

Summary

Public constructors

PhoneNumberFormattingTextWatcher()

格式化基于当前系统区域设置,将来的区域设置更改可能不会对此实例生效。

PhoneNumberFormattingTextWatcher(String countryCode)

格式是基于给定的 countryCode 。

Public methods

void afterTextChanged(Editable s)

调用此方法通知您,在 s之内的某个地方,文本已更改。

void beforeTextChanged(CharSequence s, int start, int count, int after)

这种方法被调用来通知您,内 s ,该 count在最初的文字 start即将被新文本替换长度为 after 。

void onTextChanged(CharSequence s, int start, int before, int count)

这种方法被调用来通知您,内 s ,该 count在最初的文字 start刚刚取代了长了旧文本 before 。

Inherited methods

From class java.lang.Object
From interface android.text.TextWatcher

Public constructors

PhoneNumberFormattingTextWatcher

Added in API level 1
PhoneNumberFormattingTextWatcher ()

格式化基于当前系统区域设置,将来的区域设置更改可能不会对此实例生效。

PhoneNumberFormattingTextWatcher

Added in API level 21
PhoneNumberFormattingTextWatcher (String countryCode)

格式是基于给定的 countryCode 。

Parameters
countryCode String: the ISO 3166-1 two-letter country code that indicates the country/region where the phone number is being entered.

Public methods

afterTextChanged

Added in API level 1
void afterTextChanged (Editable s)

调用此方法通知您,在s之内的某个地方,文本已被更改。 从这个回调中对s做进一步修改是合理的,但要小心不要让自己陷入无限循环,因为你所做的任何修改都会导致这个方法再次被递归调用。 (你没有被告知发生了什么变化,因为其他的afterTextChanged()方法可能已经做了其他的更改并且使得偏移无效。但是如果你需要知道这里,你可以使用setSpan(Object, int, int, int)中的onTextChanged(CharSequence, int, int, int)来标记你的位置,在这里跨度结束了。

Parameters
s Editable

beforeTextChanged

Added in API level 1
void beforeTextChanged (CharSequence s, 
                int start, 
                int count, 
                int after)

这种方法被调用来通知您,内s ,该count在最初的文字start即将被新文本替换长度为after 。 尝试从此回调中更改s是错误的。

Parameters
s CharSequence
start int
count int
after int

onTextChanged

Added in API level 1
void onTextChanged (CharSequence s, 
                int start, 
                int before, 
                int count)

这种方法被调用来通知您,内s ,该count在最初的文字start刚刚取代了长了旧文本before 。 尝试从此回调中更改s是错误的。

Parameters
s CharSequence
start int
before int
count int

Hooray!