像QQ微信那样添加发送表情

// 将表情加入到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();
}


}

你可能感兴趣的:(Android开发)