Android代码-Codeview

  • P2_419989
    了解作者
  • 133.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-05 01:00
    上传日期
Codeview http://avraampiperidis.github.io/Codeview/ Codeview is a android library tha lets you preview code in webview very easy and simple with highlighs and colors. With styles to chooses and language. Also you can inject html and text into webview or any extended webview class. This library was inspired and is working thanks to highlight.js. Apps using Codeview library. https://play.google.com/store/apps/details?id=com.protectsoft.javatutorial https://play.google.com/store/apps/detail
Android代码-Codeview.zip
内容介绍
# Codeview ------------- http://avraampiperidis.github.io/Codeview/ <br> [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Codeview-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/3999) Codeview is a android library tha lets you preview code in webview very easy and simple with highlighs and colors. With styles to chooses and language. Also you can inject html and text into webview or any extended webview class. This library was inspired and is working thanks to [highlight.js](https://highlightjs.org/). <br> Apps using Codeview library.<br> https://play.google.com/store/apps/details?id=com.protectsoft.javatutorial <br> https://play.google.com/store/apps/details?id=com.protectsoft.pythontutorial <br> https://bintray.com/zeronerone/maven/Codeview#statistics <br> Usage ----- #### Codeview #### Download/Install Gradle -------- ```groovy repositories { jcenter() } compile 'Codeview-1.0.0:webviewcode:1.0.0' ``` ##### 1) Get a reference to your WebView or any extended WebView ```java WebView webview = (WebView) findViewById(R.id.webview); //set settings here ``` ##### 2) Basic usage. Default style is Original, and default language is java. ```java //your string code String code = "public static void main(String[] args) { \n" + "\n" + "//comments\n" + " for(int i =0; i < 10; i++) {\n" + " addnum();\n" + " }\n" + "\n" + "}\n"; Codeview.with(getApplicationContext()) .withCode(code) .into(webview); ``` <img src="https://github.com/avraampiperidis/Codeview/blob/master/readmepics/pic2.png?raw=true" width="350"> ##### 3) set style and language. ```java MyTouchWebView webview = (MyTouchWebView) findViewById(R.id.mytouchwebview); //set settings here ``` ```java //your string java code String code = "public static void main(String[] args) { \n" + "\n" + "//comments\n" + " for(int i =0; i < 10; i++) {\n" + " addnum();\n" + " }\n" + "\n" + "}\n"; Codeview.with(getApplicationContext()) .withCode(code) .setStyle(Settings.WithStyle.DARKULA) .setLang(Settings.Lang.JAVA) .into(webview); ``` <img src="https://github.com/avraampiperidis/Codeview/blob/master/readmepics/pic1.png?raw=true" width="350"> ##### 4) Inject html head content and text. ```java WebView webview = (WebView) findViewById(R.id.webview); //set settings here ``` ```java //your string javascript code String code = "function Constructor(v1,v2,v3)\n" + "{\n" + " this.v1 = v1;\n" + " this.v2 = v2;\n" + " this.funk = function()\n" + " {\n" + " console.log(\"Test: \"+ v3 );\n" + " }\n" + "}\n" + "\n" + "var obj1 = new Constructor(\"par1\",\"par2\",\"par3\");\n" + "var arr = [\"w1\",\"w2\",\"w3\",obj1];\n" + "\n" + "function f2()\n" + "{ \n" + " obj1.funk(); //works ok\n" + " console.log(\"test \"+tablica[3].funk.call() ); //doesn't work\n" + "}"; 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); ``` <img src="https://github.com/avraampiperidis/Codeview/blob/master/readmepics/pic3.png?raw=true" width="350"> ## 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.
评论
    相关推荐
    • github-readme
      GitHub自述文件统计 获取自述文件中动态生成的GitHub统计信息! ·· ·· · ·· PortuguêsBrasileiro · Italiano · 한국어 。 荷兰 喜欢这个项目吗? 请考虑捐赠以帮助改善它! 特征 GitHub统计卡 GitHub...
    • dtr.http-github.io
      dtr.http-github.io-
    • VoytRuslan.github.io:http
      VoytRuslan.github.io 我的网站上有任何东西
    • airportlabs.github.io:托管 http
      机场实验室.github.io 托管
    • github搜索
      Github搜索 一个用于github搜索api简单应用。 先决条件 此项目需要NodeJS(版本8或更高版本)和NPM。 和确实很容易安装。 为确保它们在计算机上可用,请尝试运行以下命令。 $ npm -v && node -v 6.4.1 v8.16.0 安装...
    • cholnh.github.io:http
      cholnh.github.io:http
    • raihanM95.github.io:http
      raihanM95.github.io
    • github报告
      GitHub报告机器人 每周六凌晨1:00将Github的每周数据发送到闲置的频道。 环境 发展 打字稿3.7 轴距 @ slack / webhook 拉姆达 部署方式 Google云平台:在cli命令上使用gcloud sdk。 执行环境 index.js以在GCP函数...
    • kennycai.github.io:博客http
      kennycai.github.io:博客http
    • qe.github.io:http
      qe.github.io 个人简历,社交和简历简短的个人网站托管在GitHub Pages上。