// 将表情加入到EditText中
public void showFace(int pos) {
try {
Field field = R.drawable.class.getDeclaredField("bomb" + (pos + 5));
int resourceId = Integer.parseInt(field.get(null).toString());
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
resourceId);
ImageSpan imageSpan = new ImageSpan(WriteDiary.this, bitmap);
SpannableString spannableString = new SpannableString("face");
spannableString.setSpan(imageSpan, 0, 4,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
diary_et.append(spannableString);
} catch (Exception e) {
e.printStackTrace();
}
标签:QQ,int,微信,spannableString,pos,bitmap,添加,resourceId,imageSpan From: https://blog.51cto.com/u_15890522/5884205