I am working on an messenger type application where I need to add Smilies in Edit Text during chat.For adding the Smilies I need to add real smiley image not smiley string.To Achieve this I am trying to add Spanable image dynamically on a EditText
This is my code
SpannableString ss = new SpannableString("abc");
Drawable d = img.getDrawable();
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, 0, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
et.setText(ss);
I am following above code from link as How can i adding image on edittext dynamically?,
I am adding image in Edit Text and set the focus at end of Edit text where user’s text end.Smilies adding fine as I want.
Now when I want to removing smilies / adding more text to Edit Text its given unexpected output.
Sometimes it remove text instead of smilies.Sometimes when I try to add more text/smiley it also again show old smilies that I already deleted on adding more text/smiley.
Waiting for comments . . .
1 Answer