Android中显示表情图标 [英] Displaying emoticons in Android

查看:168
本文介绍了Android中显示表情图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的IM应用程序必须支持表情符号。它们是GIF和有文本重新presentations,它们用于在输入框中如果用户选择其中之一。但我想将其显示为图像,他们已经经过sent.Currently我的自定义阵列适配器显示发送的消息一排的一个TextView。

My IM app has to support emoticons. They are GIFs and have textual representations, which are used in the input box if the user selects one of them. But I'd like to display them as images after they have been sent.Currently my custom array adapter displays the sent message in a TextView of a row.

什么是正确的方法来显示动态的基础上,他们的文字重新presentation发生图像?我一定要寻找表情符号文本,如果一经发现,从布局中删除的TextView(RelativeLayout的适合大多数?),并添加一个TextView与IM,用表情和其他的TextView的ImageView的的开始。如果有更多的表情符号同时发送也可以是凌乱的。

What is the proper method to display images dynamically based on the occurrence of their textual representation? Do I have to search for emoticon texts, and if one found, remove the TextView from the layout (relativeLayout fits most?) and add a TextView with the beginning of the IM, an ImageView with the emoticon and another TextView. If more emoticons sent simultaneously it can be messy.

有没有一种更简单,更合理的方式?

Is there an easier and more logical way?

推荐答案

我会尝试使用普通的EX pression更换每一个表情符号所有出现的一个< IMG> 标记。然后,将其转换成HTML的一个 SpannedString Html.fromHtml>() 。这 SpannedString 中可以使用的setText()致电的TextView

I would try using a regular expression to replace all occurrences of each emoticon with an <img> tag. Then, convert that HTML into a SpannedString via Html.fromHtml(). That SpannedString can be used in a setText() call on TextView.

这篇关于Android中显示表情图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆