如果用户尝试从中删除某些字符,我想删除以@开头的特定文本 我试试这段代码
mBinding.questionEdtHelp.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
mPreviousLength = charSequence.length();
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (i1 - i2 == 1) {
if ( charSequence.toString().charAt(i) == '@') {
mBinding.questionEdtHelp.getText().delete(i , i1);
}
}
}
任何人都可以帮助我吗?