gpt4 book ai didi

android - 对话框中的 WebView

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:56 25 4
gpt4 key购买 nike

我有一个应用程序,我需要在 webview 中加载一个小网页。 webview 需要在对话框中加载。我试图实现它;但每次加载一个空对话框时,里面似乎没有内容。我使用的代码如下

Uri uri = Uri.parse(item.getLink());
Dialog dialog = new Dialog(this);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.webviewdialog, null);
dialog.setContentView(v);
dialog.setCancelable(true);
WebView wb = (WebView) v.findViewById(R.id.webView1);
wb.loadUrl(uri.toString());
dialog.show();

我也试过直接在 loadUrl 中放入 url,但我遇到了同样的问题。

最佳答案

试试这个:

    WebView webView = new WebView(this);
webView.loadUrl("http://www.google.com/");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Okay", null);
dialog.show();

关于android - 对话框中的 WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12888406/

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