android:webview里面的对话框或弹出窗口

roy*_*y.d 49 android android-webview

如何在对话框或弹出窗口中添加Web视图.

我的Web视图保持URL WebView.loadurl().当在对话框中添加视图时,它仍然移动到浏览器.

我一直在android中加载webview中的对话 但是没有如何做到的例子?谢谢

Dmy*_*lyk 125

这是一个例子:

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("Title here");

WebView wv = new WebView(this);
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);

        return true;
    }
});

alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
        dialog.dismiss();
    }
});
alert.show();
Run Code Online (Sandbox Code Playgroud)