简体   繁体   English

Sqlite Android中的斜体/粗体字体

[英]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: 有几个优点:

  1. Widely used around the web so your users are likely to understand how to use it. 在网络上广泛使用,因此您的用户可能会了解如何使用它。

  2. 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,这很难避免

  3. Trivial to store/export/import etc as it is all legal text string 琐碎的存储/导出/导入等,因为它们都是合法的文本字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Android TextView 中将字体样式设置为粗体、斜体和下划线? - How to set the font style to bold, italic and underlined in an Android TextView? 如何支持中文的斜体字体和粗体字体 - How to support italic font and bold font for Chinese Android将Roboto字体设置为粗体,斜体,常规,…(类似于自定义字体系列) - Android set Roboto font with bold, italic, regular,… (something like custom font family) 如何在 android studio 的 EditText Bold 或 Italic 中制作任何选定的文本并将其存储到 SQLite 数据库中? - How can I make any selected text in an EditText Bold or Italic in android studio and store it into a SQLite database? html在android中转换为粗体或斜体的字符串 - html converted bold or italic spanned string in android Android:如何以编程方式检查TextView是粗体还是斜体 - Android: How to check if TextView is bold or italic programatically 在listview android中动态更改为粗体和斜体 - Dynamically change to bold and italic in listview android 如何使EditText粗体斜体下划线android - How to make EditText bold italic underline android 在 Android EditText 中使用样式(粗体、斜体)编写文本 - Write text with style (Bold, italic) in Android EditText 在文本视图中使用自定义字体设置粗体和斜体样式(以编程方式) - Set bold and italic style in a textview with custom font (Programatically)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM