Android app: Html formatting "[]" when importing text from database - android

When I in my android application import text from my database it returns text with a square symbol. The text in the database is pasted from a webpage so I belive it is som html formatting, [ENTER] etc.
Is it possible to make the textview understand the formatting and use it as it is intended to look in a webbrowser. I am not interested in changing the view if it can be avoided, just to make the textstring use the formatting to make \nl etc.
Any one know how it can be done.

Before setting the text in the TextView you can use the Html.fromHtml method on the text, this will format the text appropriately.

Related

Spaces between tags are ignored when rendering HTML to Flutter

Let’s say I have a function that receives a string that represents a text in HTML format and I want to show this text in Flutter. Some words in the text are supposed to be bold. If I have a few bold words in a row, the spaces between the tags are ignored. How can I show the text without it ignoring spaces?
For example if I use this code and wrap the text with the Html widget:
Html(data: "<b>hello</b> <b>world</b>"),
It shows helloworld but I want it to show hello world .
(If I don’t wrap it in Html the spaces are printed but I do need to render Html to a Flutter widget)
I would really appreciate your help.
Use a non-breaking space entity ( ).I don't know if it will work or not, but you should try this.
Html(data: "<b>hello</b> <b>world</b>"),
I ended up using this line and it worked:
Html(data: text.replaceAll("</b> <b>", "</b> <b>")),

Multiline Text code highlighter for android

I need library that highlight HTML, CSS and JavaScript code. And also User can edit the code.
It seems to be hard to implement, but here is a recipe to make it.
To highlight codes in various styles, you can use https://github.com/binaryfork/Spanny work. It is appliable to TextView or EditText, as the result of Spanny is a Spannable object.
And, to analyze a text file as a HTML, CSS, JavaScript code semantic, you can use Jsoup and iterate each element in order to highlight them with styles. One example usage of Jsoup in Android is shown here.
Above two will show you highlighted output, but not editable as you type. One definite thing to do is to use EditText.addTextChangedListener event handler. Rest of editing and displaying fine Spannable result can be found from EditText with Emoticons trials.

Android: How to insert subscript in the middle of the text in sqlite3 database

I am populating into sqlite3 db from a text file and i have many superscript in the middle of the text.
Can anyone please let me know as what should i add in my text file, to make this work
In the database, all TEXT fields contain plain text.
If you want to have formatting instructions, you have to encode them somehow, e.g., as HTML:
some text <sub>with subscripts</sub> ...
or TeX:
some text \textsubscript{with subscripts} ...
This implies that you always have to ensure to escape special characters (like < or \).
What format to use depends on what software you use to actually format the text later (Android widgets typically support HTML).

Is there a way to store and display HTML with CSS to achieve text formatting in Android?

I'm creating a note taking app for Android and i would like the user to be able to format their text, i.e. bold, different text sizes.
What I would like to know is how can I do this bearing in mind the text will have to be store-able in a database.
Can i use a web view with a string of HTML i pull from the database and a custom defined CSS to style it on the user end?
I also know there is some sort of formatting class in Android but im unsure of how it work, im not convinced it would be easy to store the formatting information.
I think you should use Spannable text. See android.text.*. I think you should store the text in HTML markup. Also take a look at
http://developer.android.com/guide/faq/commontasks.html#selectingtext

How can I save text from an Edittext without loosing the features of the text like Bold, Italic etc. in Android

All I am trying to do is to get the text from the Edittext which is having the features like bold and italic and saving it in a text file but when I read it back and display it, the features are lost, they don't show. How can I maintain the rich features by saving the text in a text file or any.
You can use Html.toHtml() to convert the Editable that you get back from getText() on an EditText to an HTML representation. Then, later on, you can use Html.fromHtml() to convert the HTML back into something that can be used in an EditText. toHtml() and fromHtml() do not handle every possible span used by EditText, but it should handle the basics like bold and italics.

Categories

Resources