Giter Site home page Giter Site logo

magic-coder / customactionwebview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carguo/customactionwebview

0.0 2.0 0.0 142 KB

自定义webview长按文本弹出选项,并且点击后返回选项与所选中的文本,你的webview不再只支持系统的复制等功能了,长按web文本实现文本一键收藏、分享,就是这么简单。Demo中附带对webView的详细使用:api详解,配置详解,js多种通信方式详解。

Home Page: http://www.jianshu.com/p/16713361bbd3

HTML 4.87% Java 95.13%

customactionwebview's Introduction

自定义webview长按文本弹出选项,并且点击后返回选项与所选中的文本,你的webview不再只支持系统的复制等功能了,长按web文本实现文本一键收藏、分享,就是这么简单。Demo中附带对webView的详细使用:api详解,配置详解,js多种通信方式详解。


Build Status

在project下的build.gradle添加

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

在module下的build.gradle添加

dependencies {
   compile 'com.github.CarGuo:CustomActionWebView:v1.0.1'
}

示例图

JPG

GIF

使用实例

和普通的webview使用基本一致

List<String> list = new ArrayList<>();
list.add("Item1");
list.add("Item2");
list.add("Item3");

mCustomActionWebView.setWebViewClient(new bViewClient());

//设置item
mCustomActionWebView.setActionList(list);

//链接js注入接口,使能选中返回数据
mCustomActionWebView.linkJSInterface();

ctionWebView.getSettings().setBuiltInZoomContro;
ctionWebView.getSettings().setDisplayZoomContro);
//使用javascript
ctionWebView.getSettings().setJavaScriptEnabled
ctionWebView.getSettings().setDomStorageEnabled


//增加点击回调
ctionWebView.setActionSelectListener(new lectListener() {
    @Override
    public void onClick(String title, String xt) {
        Toast.makeText(MainActivity.this, tem: " + title + "。\n\nValue: " + selectText, NGTH_LONG).show();
    }
});

//加载url
mCustomActionWebView.postDelayed(new Runnable() 
    @Override
    public void run() {
        mCustomActionWebView.loadUrl("http://shu.com/p/b32187d6e0ad");
    }
}, 1000);

webView使用详细解析

  • Demo中的APIWebViewActivity.java
/**
 * 演示WebView中的Api说明、js交互的方法,还有注意事项
 * <p>
 * 1、内存泄漏防备
 * 2、配置webView
 * 3、页面加载开始,错误,拦截请求,接受Error等
 * 4、页面加载进度,title,图标,js弹框等
 * 5、js交互与安全
 */

其他WebView推荐

customactionwebview's People

Contributors

carguo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.