1

I am trying to load my html file which is located in the raw folder (android) to a textview. i tried to simply copy the content of my html file to a String variable and just put it in this syntax:

MyTextView.setText(Html.fromHtml(myStringVariable));

the problem is the content is too long. is there another way to do this.

Requirement: 1. The app should be able to view the content of the HTML file on the TextView

note: the html file has 1346 lines of code.

Dan Arenas
  • 19
  • 1
  • 6
  • `TextView` aren't really designed for html. Use `WebView` instead. – Shaishav Aug 13 '16 at 16:38
  • Thank you for that suggestion. I tried that already, but using a WebView will make my app laggy for some reason. I made a research on that for almost 2 days all solutions that came from this site didn't. I could do that, but it would be best if i use TextView. @Shaishav – Dan Arenas Aug 13 '16 at 16:42
  • Possible duplicate of [How to display HTML in TextView?](http://stackoverflow.com/questions/2116162/how-to-display-html-in-textview) –  Aug 13 '16 at 17:41
  • I think you should use `TextArea` for long pieces of text. :) It's a `TextView` with scroll capability. – Masked Man Aug 13 '16 at 17:44
  • @DarioAckermann I tried that solution. the problem still exists. the content of my html file is too long. it has 1346 lines all in all. the String cant hold it i dont know why. – Dan Arenas Aug 13 '16 at 18:52
  • @MaskedMan I will try that ASAP, but still I cant save my HTML contents in a String because Android studio tells me that the string is too long. just like this error i saw. http://stackoverflow.com/questions/2738574/java-constant-string-too-long-compile-error-only-happens-using-ant-not-when – Dan Arenas Aug 13 '16 at 18:54
  • So you should read your string in small chunks. – Masked Man Aug 13 '16 at 20:17

0 Answers0