以下代码片段用于文本观察器...它不起作用...一切正常,直到最后一行代码...
private TextWatcher mobileTextWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
String number = s.toString();
number = AppConstants.convertToOnlyDigits(number);
Editable temp = new SpannableStringBuilder(
AppConstants.formatPhoneNumber(number));
s = temp;
}
};
之后,新的不会分配给 s.. 或者换句话说,我看不到编辑文本中文本的变化。