3

我的问题是这样的,我设法在 中正确显示表情符号EditText,但是如果用户尝试在某些设备中删除此表情符号,则在按一次键盘删除图标后删除而不是删除表情符号,则需要按两三个根据表情符号串的时间

下面是我的代码:

Drawable d = getResources().getDrawable(emoticon.getResourceId());    
int startCursor = mTextInput.getSelectionStart();
int endCursor = mTextInput.getSelectionEnd();
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(emoticon.getStr());
builder.setSpan(new ImageSpan(d), builder.length() - emoticon.getStr().length(), builder.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mTextInput.getText().replace(startCursor, endCursor, builder);
4

0 回答 0