储存Spannable为字符串 [英] Storing Spannable to a string

查看:137
本文介绍了储存Spannable为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个聊天应用程序,并解析表情图标我用code从这里的在android系统显示表情图标

我的聊天文本存储就像一个ArrayListSENDER | | TIME NON_PARSED_CHAT_TEXT

问题是,我有一个字符串的所有聊天信息(时间,发件人和聊天文本),和我分开,并在ListView连续显示它,每次我得到这个聊天文本,重新解析它的表情图标,有存储Spannable对象(聊天文本分析后,从结果中提供的有关功能),字符串中的时间和发送一个ArrayList任何可能的方式?

感谢


解决方案

  

有存储Spannable对象(聊天文本分析后,从结果中提供的有关功能),字符串中的时间和发送一个ArrayList任何可能的方式?


欢迎您使用<一个href=\"http://developer.android.com/reference/android/text/Html.html#toHtml%28android.text.Spanned%29\"相对=nofollow> toHtml() HTML 类,尽管这只能处理一些HTML输出,不是任意的东西。

您也可以有一个持有的ArrayList Spannable 而非字符串的是转换 Spannable

i'm writing a chat application, and to parse emotion icons i use code from here displaying emoticons in android

my chat text is stored like "SENDER|TIME|NON_PARSED_CHAT_TEXT" in an ArrayList

the problem is that i have all chat messages (time and sender and chat text) in a single string, and i split it and display it in a row in a ListView, each time i get this chat text and re-parse it for the emotion icons, is there any possible way to store Spannable object (chat text after parsing resulted from the function in the question provided) to string in an ArrayList with the time and sender?

thanks

解决方案

is there any possible way to store Spannable object (chat text after parsing resulted from the function in the question provided) to string in an ArrayList with the time and sender?

You are welcome to use toHtml() on the Html class, though that can only handle some HTML output, not arbitrary things.

You could also have an ArrayList that holds the Spannable rather than a String conversion of that Spannable.

这篇关于储存Spannable为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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