提供一个小思路:删除图片,其实就是重置EditText文本. 添加图片用SpannableString ImageSpan,关键代码如下:
SpannableString ss = new SpannableString(getText().toString()+"[smile]");
Drawable d = getResources().getDrawable(id);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, getText().length(),getText().length()+"[smile]".length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
setText(ss);
转载:http://www.adobex.com/android/source/details/00000018.htm