1) Get a reference to your WebView or any extended WebView

WebView webview = ( WebView ) findViewById( R . id . webview); // set settings here

2) Basic usage. Default style is Original, and default language is java.

// your string code String code = " public static void main(String[] args) {

" + "

" + " //comments

" + " for(int i =0; i < 10; i++) {

" + " addnum();

" + " }

" + "

" + " }

" ; Codeview . with(getApplicationContext()) .withCode(code) .into(webview);

3) set style and language.

MyTouchWebView webview = ( MyTouchWebView ) findViewById( R . id . mytouchwebview); // set settings here

// your string java code String code = " public static void main(String[] args) {

" + "

" + " //comments

" + " for(int i =0; i < 10; i++) {

" + " addnum();

" + " }

" + "

" + " }

" ; Codeview . with(getApplicationContext()) .withCode(code) .setStyle( Settings . WithStyle . DARKULA ) .setLang( Settings . Lang . JAVA ) .into(webview);

4) Inject html head content and text.

WebView webview = ( WebView ) findViewById( R . id . webview); // set settings here

// your string javascript code String code = " function Constructor(v1,v2,v3)

" + " {

" + " this.v1 = v1;

" + " this.v2 = v2;

" + " this.funk = function()

" + " {

" + " console.log( \" Test: \" + v3 );

" + " }

" + " }

" + "

" + " var obj1 = new Constructor( \" par1 \" , \" par2 \" , \" par3 \" );

" + " var arr = [ \" w1 \" , \" w2 \" , \" w3 \" ,obj1];

" + "

" + " function f2()

" + " {

" + " obj1.funk(); //works ok

" + " console.log( \" test \" +tablica[3].funk.call() ); //doesn't work

" + " } " ; Codeview . with(getApplicationContext()) .setHtmlHeadContent( " <style> table,tr,td { " + " border: 1px solid black; " + " } " + " " + " </style> " ) .withHtml( " <h1> h1 injected header</h1> " ) .withText( " this text is always wrap inside pre tags " ) .withCode(code) .withHtml( " <h1> h1 header after code </h1> " ) .withHtml( " <table><tr><td> my html table </td></tr></table> " ) .setStyle( Settings . WithStyle . DARKSTYLE ) .setLang( Settings . Lang . JAVASCRIPT ) .setAutoWrap( true ) .into(webView);

License

MIT License

Copyright (c) 2016 Avraam Piperidis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.