@消息界面删除逻辑补充

This commit is contained in:
18401019693 2022-10-08 18:26:05 +08:00
parent e2095f6e46
commit a6004941ad

View File

@ -37,10 +37,10 @@ public class AtTextWatcher implements TextWatcher {
int endIndex = startIndex + nameStr.length();//字符结束的位置 int endIndex = startIndex + nameStr.length();//字符结束的位置
spanMap.put(model.getId(), model); spanMap.put(model.getId(), model);
//插入要添加的字符此处是为了给span占位 //插入要添加的字符此处是为了给span占位
input.getText().insert(startIndex, "@" + nameStr + " "); input.getText().insert(startIndex, "@" + nameStr);
//1使用mEditText构造一个SpannableString //1使用mEditText构造一个SpannableString
StringBuffer atName = new StringBuffer(); StringBuffer atName = new StringBuffer();
atName.append("@").append(nameStr).append(" "); atName.append("@").append(nameStr);
if (spannableStringBuilder.length() > 0) { if (spannableStringBuilder.length() > 0) {
spannableStringBuilder.insert(startIndex, atName.toString()); spannableStringBuilder.insert(startIndex, atName.toString());
} else { } else {