Search code examples
androidtextview

How to can i add emoji in text using emoji library?


I want to add an emoji to a predefined text view. User no need to change that. How can i achieve this

"Hi there 😀!"

in TextView

in Android using emoji library ? Do i need to use emoji library ?


Solution

  • You don't need a library for this.

    Method 1

    Suppose you have a textview, then try this

    textView.setText(new String(Character.toChars(0x1F60A)));
    

    where 0x1F60A is the unicode for your smiley

    Alternate Method

    add this resource in strings.xml

    <string name="smiley_text">&#x1F60A;</string>

    then add it to textview like below

    textview.setText(R.string.smiley_text);