How to set emoji by unicode in a textview? - py4u
文章推薦指數: 80 %
??? unicode = U+1F60A String emoji = getEmojiByUnicode(unicode) String text = "So ...
Howtosetemojibyunicodeinatextview?
HiI'dliketodothefollowing:
???unicode=U+1F60A
Stringemoji=getEmojiByUnicode(unicode)
Stringtext="Sohappy"
textview.setText(text+emoji);
togetthisinmytextview:
Sohappy?
HowcanIimplementgetEmojiByUnicode(unicode)?
Whattypeshouldtheunicodevariablebe?(String,char,int?)
PleasenotethatIdoNOTwanttouseDrawables!
AskedBy:GilbertGiesbert||Source
Answer#1:
Foundasolution:
InmyunicodeIreplaced'U+'by'0x'
Example:replace'U+1F60A'by'0x1F60A'
ThiswayIgotan'int'like
intunicode=0x1F60A;
Whichcanbeusedwith
publicStringgetEmojiByUnicode(intunicode){
returnnewString(Character.toChars(unicode));
}
SoTextviewdisplays?withoutDrawable
Tryitwithhttp://apps.timwhitlock.info/emoji/tables/unicode
AnsweredBy:GilbertGiesbert
Answer#2:
YoucandirectlyuseEmojisinstringresourcesbyusingthedecimalcodelikethis:
😊
forexample:
延伸文章資訊
- 1How to set emoji by unicode in a textview? - py4u
??? unicode = U+1F60A String emoji = getEmojiByUnicode(unicode) String text = "So ...
- 2Emoji Compatibility | Android Developers
It also updates the necessary emoji metadata that the EmojiCompat support library needs to keep u...
- 3android - 如何在TextView 中通过unicode 设置表情符号?
嗨,我想执行以下操作: ??? unicode = U+1F60A String emoji = getEmojiByUnicode(unicode) String text = "So hap...
- 4How to set emoji by unicode in a textview? | Newbedev
So Textview displays without Drawable. Try it with http://apps.timwhitlock.info/emoji/tables/unic...
- 5android - How to set emoji by unicode in a textview? - OStack.cn
??? unicode = U+1F60A String emoji = getEmojiByUnicode(unicode) String text = "So happy " textvie...