Hi I'd like to do the following:
??? unicode = U+1F60A String emoji = getEmojiByUnicode(unicode) String text = "So happy " textview.setText(text + emoji);
to get this in my textview:
So happy 😊
How can I implement getEmojiByUnicode(unicode)
?
What type should the unicode
variable be? (String, char, int?)
Please note that I do NOT want to use Drawables!
Unicode provides a number of emoji resources which provides more information about emoji. In particular, Unicode Emoji TR #51 outlines many details of the entire emoji set. For questions about new emoji proposals or why a certain emoji does not exist, please see the Emoji Submission FAQ.
Emojis look like images, or icons, but they are not. They are letters (characters) from the UTF-8 (Unicode) character set.
Found a solution:
In my unicode I replaced 'U+' by '0x'
Example: replace 'U+1F60A' by '0x1F60A'
This way I got an 'int' like
int unicode = 0x1F60A;
Which can be used with
public String getEmojiByUnicode(int unicode){ return new String(Character.toChars(unicode)); }
So Textview displays 😊 without Drawable
Try it with http://apps.timwhitlock.info/emoji/tables/unicode
You can directly use Emojis in string resources by using the decimal code like this:
😊
for example:
<string name="emoji">I am happy 😊</>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With