{"id":15627351,"url":"https://github.com/carguo/customactionwebview","last_synced_at":"2025-04-09T10:06:49.579Z","repository":{"id":107562976,"uuid":"94616935","full_name":"CarGuo/CustomActionWebView","owner":"CarGuo","description":"自定义webview长按文本弹出选项，并且点击后返回选项与所选中的文本，你的webview不再只支持系统的复制等功能了，长按web文本实现文本一键收藏、分享，就是这么简单。Demo中附带对webView的详细使用：api详解，配置详解，js多种通信方式详解。","archived":false,"fork":false,"pushed_at":"2017-12-18T14:18:20.000Z","size":143,"stargazers_count":376,"open_issues_count":4,"forks_count":70,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-02T03:28:16.475Z","etag":null,"topics":["actionmode","webview"],"latest_commit_sha":null,"homepage":"http://www.jianshu.com/p/16713361bbd3","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CarGuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-17T10:33:43.000Z","updated_at":"2025-03-28T01:15:24.000Z","dependencies_parsed_at":"2023-06-08T12:15:52.507Z","dependency_job_id":null,"html_url":"https://github.com/CarGuo/CustomActionWebView","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FCustomActionWebView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FCustomActionWebView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FCustomActionWebView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FCustomActionWebView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CarGuo","download_url":"https://codeload.github.com/CarGuo/CustomActionWebView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018060,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionmode","webview"],"created_at":"2024-10-03T10:16:29.090Z","updated_at":"2025-04-09T10:06:49.555Z","avatar_url":"https://github.com/CarGuo.png","language":"Java","readme":"### 自定义webview长按文本弹出选项，并且点击后返回选项与所选中的文本，你的webview不再只支持系统的复制等功能了，长按web文本实现文本一键收藏、分享，就是这么简单。Demo中附带对webView的详细使用：api详解，配置详解，js多种通信方式详解。\n-------------------\n\n[![](https://jitpack.io/v/CarGuo/CustomActionWebView.svg)](https://jitpack.io/#CarGuo/CustomActionWebView)\n[![Build Status](https://travis-ci.org/CarGuo/CustomActionWebView.svg?branch=master)](https://travis-ci.org/CarGuo/CustomActionWebView)\n\n\n## [实现解析](http://www.jianshu.com/p/16713361bbd3)\n\n#### 在project下的build.gradle添加\n```\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\n#### 在module下的build.gradle添加\n```\ndependencies {\n   compile 'com.github.CarGuo:CustomActionWebView:v1.0.1'\n}\n```\n\n### 示例图\n\n### JPG\n\n![](https://ooo.0o0.ooo/2017/06/17/59450eac66a3a.jpg)\n![](https://ooo.0o0.ooo/2017/06/17/59450eae894c5.jpg)\n\n### GIF\n\n![](https://ooo.0o0.ooo/2017/06/17/59450f5c52301.gif)\n\n\n### 使用实例\n\n和普通的webview使用基本一致\n\n```\nList\u003cString\u003e list = new ArrayList\u003c\u003e();\nlist.add(\"Item1\");\nlist.add(\"Item2\");\nlist.add(\"Item3\");\n\nmCustomActionWebView.setWebViewClient(new bViewClient());\n\n//设置item\nmCustomActionWebView.setActionList(list);\n\n//链接js注入接口，使能选中返回数据\nmCustomActionWebView.linkJSInterface();\n\nctionWebView.getSettings().setBuiltInZoomContro;\nctionWebView.getSettings().setDisplayZoomContro);\n//使用javascript\nctionWebView.getSettings().setJavaScriptEnabled\nctionWebView.getSettings().setDomStorageEnabled\n\n\n//增加点击回调\nctionWebView.setActionSelectListener(new lectListener() {\n    @Override\n    public void onClick(String title, String xt) {\n        Toast.makeText(MainActivity.this, tem: \" + title + \"。\\n\\nValue: \" + selectText, NGTH_LONG).show();\n    }\n});\n\n//加载url\nmCustomActionWebView.postDelayed(new Runnable() \n    @Override\n    public void run() {\n        mCustomActionWebView.loadUrl(\"http://shu.com/p/b32187d6e0ad\");\n    }\n}, 1000);\n```\n\n### webView使用详细解析\n\n* Demo中的APIWebViewActivity.java\n```\n/**\n * 演示WebView中的Api说明、js交互的方法，还有注意事项\n * \u003cp\u003e\n * 1、内存泄漏防备\n * 2、配置webView\n * 3、页面加载开始，错误，拦截请求，接受Error等\n * 4、页面加载进度，title，图标，js弹框等\n * 5、js交互与安全\n */\n```\n\n### 其他WebView推荐\n\n* [Android开发：最全面、最易懂的Webview使用详解](http://www.jianshu.com/p/3c94ae673e2a)\n* [最全面总结 Android WebView与 JS 的交互方式](http://www.jianshu.com/p/345f4d8a5cfa)\n* [你不知道的 Android WebView 使用漏洞](http://www.jianshu.com/p/3a345d27cd42)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarguo%2Fcustomactionwebview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarguo%2Fcustomactionwebview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarguo%2Fcustomactionwebview/lists"}