简体   繁体   中英

how to set multiple spanned with text on text view in android

I am working on chat. I want to set all emoji icon on text view with text. I have tried by many way but either I am able to set text or a single emojiicon on text. How to set multiple emoji icon with text on text? I have search lots of on google but I did not find anything with working mode.

String text = "hello";                                
for (int i = 0; i < emojilist.length-1; i++) {
    Spanned cs = Html.fromHtml("<img src ='"+ emojilist[i] +"'/>",
        imageGetter, null); 
    textviewobject.setText(cs);
}

Try:

String html="";
for (int i = 0; i < emojilist.length-1; i++) { 
     html += "<img src ='"+ emojilist[i] +"'/>";
}

Spanned cs = Html.fromHtml(html, imageGetter, null); 
textviewobject.setText(cs);

And if you want to use SpannableString try: SpannableString with Image example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM