就像实现del按钮功能一样
如何通过 EditText.getSelectionStart() 删除 EditText 中的 SpannableString
private void enterExpression(String imageFile) {
try {
Field field = R.drawable.class.getDeclaredField(imageFile);
int resourceId = Integer.parseInt(field.get(null).toString());
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
resourceId);
ImageSpan imageSpan = new ImageSpan(bitmap);
SpannableString spannableString = new SpannableString("[/"
+ imageFile + "]");
spannableString.setSpan(imageSpan, 0, spannableString.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sendContentEdt.append(spannableString);
} catch (Exception e) {
LogUtils.e(TAG, "enterExpressionException:" + e.getMessage());
}
}