@消息界面删除逻辑补充

This commit is contained in:
18401019693 2022-10-08 18:24:05 +08:00
parent 8cf76a13e0
commit e2095f6e46

View File

@ -7,7 +7,6 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import com.yunbao.common.bean.OlineUserlistModel;
@ -38,11 +37,16 @@ public class AtTextWatcher implements TextWatcher {
int endIndex = startIndex + nameStr.length();//字符结束的位置
spanMap.put(model.getId(), model);
//插入要添加的字符此处是为了给span占位
input.getText().insert(startIndex, "@" + nameStr);
input.getText().insert(startIndex, "@" + nameStr + " ");
//1使用mEditText构造一个SpannableString
StringBuffer atName = new StringBuffer();
atName.append("@").append(nameStr);
atName.append("@").append(nameStr).append(" ");
if (spannableStringBuilder.length() > 0) {
spannableStringBuilder.insert(startIndex, atName.toString());
} else {
spannableStringBuilder.append(atName.toString());
}
AtUserForegroundColorSpan span = new AtUserForegroundColorSpan(Color.parseColor("#2a92f7"));
span.setAtContent(atName.toString());
span.setUid(model.getId());