[英]Italic/Bold font in Sqlite Android
I m working on app which uses sqlite database . 我正在开发使用sqlite数据库的应用程序。 I got sucess to store Strings in various languages and also fetching from database .
我成功地存储了各种语言的字符串,并且还从数据库中获取了字符串。
But My problem is that i want to store it in bold or italic style. 但是我的问题是我想以粗体或斜体样式存储它。
Is it possible ?? 可能吗 ?? If yes then how can i achieve that kind of thing ?
如果是,那我该怎么做呢?
Any help will be appreciated. 任何帮助将不胜感激。
Format the strings using html. 使用html格式化字符串。
When you want to display them use Html.fromhtml( your string)
当您要显示它们时,请使用
Html.fromhtml( your string)
Eg 例如
String myboldstring = <b>boldy</b>
textView.setText(Html.fromhtml(myboldstring));
Is it what you want? 是你想要的吗?
As an alternative to LazyN's solution I suggest you look at using a standard markdown language for this kind of context (much as stack overflow does). 作为LazyN解决方案的替代方案,我建议您考虑针对这种上下文使用标准的markdown语言(就像堆栈溢出一样)。 There are several advantages:
有几个优点:
Widely used around the web so your users are likely to understand how to use it. 在网络上广泛使用,因此您的用户可能会了解如何使用它。
Much more secure in the sense that one cannot inject malicious HTML/javascript; 从某种意义上说,它不能注入恶意的HTML / javascript更加安全。 this is very difficult to prevent once you allow any HTML as LazyN suggests
一旦您允许任何LazyN建议的HTML,这很难避免
Trivial to store/export/import etc as it is all legal text string 琐碎的存储/导出/导入等,因为它们都是合法的文本字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.