android集成多个5+webview

来源:互联网 发布:中国金融战略2020知乎 编辑:程序博客网 时间:2024/04/29 14:20

5+webview只需要集成一次时,按照Dcloud官方文档集成。

如果需要集成多次,在之后的activity中只需要调用SDK.creatWebview方法,创建出webview,然后添加到布局文件中即可

final FrameLayout rootView = (FrameLayout) findViewById(R.id.frameLayout);//使用自己的布局rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {    @Override    public void onGlobalLayout() {        webview.onRootViewGlobalLayout(rootView);    }});webview = SDK.createWebview(this, url, new IWebviewStateListener() {    @Override    public Object onCallBack(int i, Object pArgs) {        switch (i) {            case IWebviewStateListener.ON_WEBVIEW_READY:                View view = LayoutInflater.from(App.getcontext()).inflate(R.layout.dcloud_loadingview, null);                rootView.addView(view);                ((IWebview) pArgs).obtainFrameView().obtainMainView().setVisibility(View.INVISIBLE);                SDK.attach(rootView, ((IWebview) pArgs));                break;            case IWebviewStateListener.ON_PAGE_STARTED:                break;            case IWebviewStateListener.ON_PROGRESS_CHANGED:                break;            case IWebviewStateListener.ON_PAGE_FINISHED:                webview.obtainFrameView().obtainMainView().setVisibility(View.VISIBLE);                break;        }        return true;    }});

原创粉丝点击