I am creating a note application for myself. To style my notes, I write html tags, click a button and show styled version with html. from html.. But the problem is, I need to store the text with html tags not without it so when I get the data from the database, I get the text with style.
So I wonder is there any way to decode embedded html tags other than storing the string before html. from html function and acting accordingly? Also i can click the button anytime then continue typing which is very hard to track. Because i run this function to stylize ;
text.setText(Html.fromHtml(text.getText().toString()));
Which means i lose the tag info.
Thanks in advance.
If the user of the app write the html tags, the app should store them.
So as you suggest yourself, you will have to store the string before calling Html.fromHtml.
Related
I have html string. I need to show my it in my TextView. Here is my code:
tvText.setText(Html.fromHtml(htmlString));
Html string contains some text, but may also contains links. I need to detect if a string contains a link, make part of that string clickable.
I can do a search for links in a string myself and then use SpannableString and ClickableSpan.
But perhaps there is some way to set a click in html and then the mobile application will be able to react for some reason and make part of the string clickable.
Please help me.
UPD: I can request an html string in any form, so I need to understand what it should be in order to process a click in a mobile application without any search for links in string.
Try to wrap your links in html <a> tags and set movement method to your textView like this:
textView.setText(Html.fromHtml("This is a link"));
textView.setMovementMethod(LinkMovementMethod.getInstance());
My program works like this:
I have a WebView that loads assets/index.html. In this HTML I have the "Download Button", and am using Ajax to call a function to download HTML from a website. Then, the user has an option to open this downloaded HTML file inside the WebView (using the myWebView.loadUrl).
How can I make the user allowed to "edit" the HTML? I want them to be able to select text and edit the colour/font/background/bold/italic/etc. and then save and it update the HTML file with the edited text (probably with tags, <b><i>Edited Text</b></i> in the place of the normal edited text?
I think it is better to use JavaScript to do this, then when they click "Save", it calls a method to save and the next time the user clicks to "See the html in the WebView" it shows the styled text.
How can I do this? Maybe using JavaScript/jQuery text Editor like this (http://jqueryte.com/demos)?
I don't know about performance issues, since every time the user edits something the application will have to parse from file, show in WebView, edit, than write again full text to the file.
Can anyone offer some examples? directions? or better advice?
Add attribute contenteditable to your <body>
<body contenteditable='true'>
Now your <body> is editable.
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
I have textview in my app. I have a string which I set in the textview.
The string is HTML string which has lots of html like images, bold and italics.
I used code as follows:
content.setText(Html.fromHtml(articledet.toString(), imgGetter, null));
I just want the links should be click-able. I achieved that easily. What I want when user clicks on the link, link should be opened in browser but I also want to track what external links where clicked.
i.e. On click of link, I should be able to write URL in a file.
I can do that using spanned. But if I used spanned then, I have load images, that will stop working.
Please help me with this.
I want to display about one or two full screens worth of text in an Android application (like a welcome screen or help screen), and I'm trying to figure out the best way of storing that text in the app. The text does not need formatting, but line breaks and empty lines must be preserved.
So far I have come up with the following alternatives:
Store the text in a long string in an XML file in res/values, access it like any other string and display it in a TextView. But then what is the proper way of handling line breaks, etc?
Store it in a text file in res/raw, read that from the application and display it in a TextView. Again, do I need to consider line breaks, etc, in this case?
Store it in an HTML file and display it in a WebView. Then how and where should I store the HTML file?
And there are likely more ways that I haven't thought of yet.
Is there a common way of achieving this? I would greatly appreciate sample code as well!
IMHO the most effective way would be setting up one or more strings within the strings.xml and using the \n escape sequence to force a linebreak whenever needed.
If you want to display your data directly as a WebView you should consider storing it within res/html.
But storing an extra text file within res/raw and reading it every time you want to access it doesn't seem very efficient.