https://gitee.com/Pino_W/ait.git
记录一下
mBinding.atEdittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// 从start开始的count个字符将会被一个新的长度为after的文本替换,注意这里是将被替换,还没有被替换
Editable editable = mBinding.atEdittext.getText();
// 光标起始为止如果不是在最后,那对于在光标后面的文字块都要做偏移
if (start < editable.length()) {
int end = start + count;
int offset = after - count;
whenDelText(start, end, offset);
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (count == 1 && !TextUtils.isEmpty(s)) {
char mentionChar = s.toString().charAt(start);
int selectionStart = mBinding.atEdittext.getSelectionStart();
if (mentionChar == &