How to set emoji by unicode in a textview? - py4u

文章推薦指數: 80 %
投票人數:10人

??? 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: Iamhappy😊> AnsweredBy:P1xelfehler Answer#3: Note:ForKotlin fungetEmoji(unicode:Int):String{ returnString(Character.toChars(unicode)) } AnsweredBy:BipinBharti Theanswers/resolutionsarecollectedfromstackoverflow,arelicensedunderccby-sa2.5,ccby-sa3.0andccby-sa4.0. #MoreArticles Use“ENTER”keyonsoftkeyboardinsteadofclickingbutton AndroidFragmentonClickbuttonMethod Howtoopenasecondactivityonclickofbuttoninandroidapp GetmarginofaView Ilostmy.keystorefile? Isitpossibletochangetheradiobuttoniconinanandroidradiobuttongroup Progressbarwithroundedcorners? RetrofitandGETusingparameters Howtofindthelogsonandroidstudio? AndroidSQLite:nullColumnHackparameterininsert/replacemethods Androidcontext.getResources.updateConfiguration()deprecated WarningsYourApkIsUsingPermissionsThatRequireAPrivacyPolicy:(android.permission.READ_PHONE_STATE) EditTextaddedisnotaTextInputEditText.Pleaseswitchtousingthatclassinstead androidtoolbarpopupThemevstheme WhatisthedifferencebetweenActivityandContext? RemotedebuggingwithAndroidemulator APItoautomaticallyuploadapktoGooglePlay?[closed] Android,Detectwhenotherappsarelaunched Whatcausessignal'SIGILL'?



請為這篇文章評分?