简体   繁体   中英

Italic/Bold font in Sqlite Android

I m working on app which uses sqlite database . 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.
When you want to display them use 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). 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; this is very difficult to prevent once you allow any HTML as LazyN suggests

  3. Trivial to store/export/import etc as it is all legal text string

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