Henry Thompson Henry Thompson - 1 year ago 142
Android Question

Android: Syntax Highlighting?

I am currently trying to write an application which invloves syntax highlighting codes. (HTML, XML, PHP, JavaScript, CSS and preferably more).

It has been going very well but I have come across a probelm: syntax highlighting. I have written a class for syntax highlighting XML myself, but it is incredibly slow, inefficient and takes so long. I loaded, as a test, a 600 line XML document, and it took two whole minutes to syntax highlight. What do people recommend for Syntax Highlighting on Android? Are there any good libraries? Are there any good algorithms I can use (I don't mind rewriting it from another language), or any standard techniques? What about Regex?

I also have the problem that when I did the 600-line XML test yesterday the EditText widget I was using could not cope with the coloured text and eventually I recieved a ANR error, but that is a different question I will post elsewhere, though if anyone does incidentally have a solution that would be great.

Thanks so much!

Answer Source

You already have a lots of syntax highlighting tools available in Javascript. You may need to do slight modifications. Take a look at this. I use it in my blog everyday.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download