gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-28 23:46:51 27 4
gpt4 key购买 nike

如何在对话框或弹出窗口中添加网页 View 。

我的 WebView 保存 URL WebView.loadurl()。当 View 添加到对话框中时,它仍然移动到浏览器。

我去过android loading webview in dialog但是没有例子怎么做呢?谢谢

最佳答案

示例如下:

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();

关于android:对话框或弹出窗口内的 webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9172805/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com