首页 > 其他分享 >像QQ微信那样添加发送表情

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

时间:2022-11-24 17:05:50浏览次数:41  
标签:QQ int 微信 spannableString pos bitmap 添加 resourceId imageSpan


// 将表情加入到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

相关文章