当前位置: 代码迷 >> Android >> webview 如何实现window.open 创建新窗口的
  详细解决方案

webview 如何实现window.open 创建新窗口的

热度:27   发布时间:2016-05-01 10:33:12.0
webview 怎么实现window.open 创建新窗口的
android 怎么实现window.open和自带浏览器一样的效果,就是在原有的webview上新建一个webview,但不是全屏,右上角有个关闭按钮!表达能力不好,效果图如下:
WebView Android window.open js 新窗口

------解决方案--------------------

public class TutorialView extends RelativeLayout {

    private View baseView;

    public TutorialView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
    }

    public TutorialView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        mContext = context;
    }

    public TutorialView(Context context) {
        this(context, null);
        mContext = context;
    }

    public TutorialView(Context context, int step) {
        this(context);
        this.step = step;
        mContext = context;
        init();
    }

    private void init() {
        baseView = LayoutInflater.from(mContext).inflate(
                R.layout.my_relative_view, this);
    }
}


这样就可以了。具体的逻辑你可以写到init里,比如webView的内容啊,closebutton的监听啊。或者加一些其他的方法。
  相关解决方案