How can I insert emoji/smiley/emoticons in an input method editor (in soft keyboard) ? which method should I use for that purpose?
- To create a True type font ? (I think that the font comes in one color)
- To use SpannableStringBuilder and attatch the emoticons to the string in it?
- or another method?
NOTE : I'm not asking for code .. Just for the method.
Note :
I used the following function:
public CharSequence addSmileySpans(CharSequence text) {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.smiley);
SpannableStringBuilder builder = new SpannableStringBuilder(text);
builder.setSpan(new ImageSpan(this,bm), 1,3,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
and I called it like this
getCurrentInputConnection().setCommitText(addSmileySpans("123"),1);
The result was printing the 123
in the editor without the smiley.