I am writing an android application that will be displaying codes... specially java codes, or maybe jsp code as well. I was thinking about placing these codes in a TextView. However i dont know how to do this for android. I didnt find any tutorial or documentation on how to display formated text in a TextView. I know I can put html in there, so one direction would be format the code itself in html and then place it in the textview.
Is there a better way to do that?
Many thanks
T
TExtView can't do all the formatting. HTML is the best guess.
Search for "Spannable HTML Textview Android" and you will get quite a few examples. Here is one.
Is it possible to have multiple styles inside a TextView?
Related
I have gone through this link for reference
https://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
The information is right there on your link. To use it as a spannable you have to call the fromHtml() method on your textview. After initializing the component. Please refer to this question:
How to display HTML in TextView?
All your answers are there, sorry for not formatting the answer correctly I'm on mobile at the moment
I am creating a mathematics app and have to display mathematical equations in my app. There are many answers related to this but I am not able to conclude how to do this?
As mentioned in the comments above you can use that library MathView or other possibilities are ,
You can go with using the spannable string and can make superscripts
and subscripts easily.
You can also use the HTML.fromHTML(String html) which will give you
the spanned text and that you can set it to the TextView.
Or else show a webview and load the html page that contains the
formulas and solutions. (This will be like creating a dynamic html
files with in the app and showing it in the Webiew)
For example, doing centered text and underlined etc... could be possible with a lot of textviews but is there a way not to use that much? Or maybe a way to type html and have the result?
How about use HTML tag?
myTextView.setText(Html.fromHtml("<u>Underlined</u>"));
Help somebody, I am stuck.
The goal is to view html text with pictures and etc. and to be able catch longClick events on pieces of plain text. And then get this txt and do something with it.
If you are writing a custom application to load html documents then you should have the look at WebView documentation for it. It contains everything to guide you.
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