gpt4 book ai didi

android - Webview 不是每次都加载

转载 作者:行者123 更新时间:2023-11-29 01:55:29 24 4
gpt4 key购买 nike

我有一个 Webview,它必须从 assets 文件夹加载静态网页。该网页包含一个完美运行的javascript函数。问题是每隔一段时间当 Activity 启动时,网页永远不会出现(而且经常出现。启动 Activity 也包含 webview)

有时当 webview 加载时,您导航到另一个 Activity 然后返回,有时 webview 不会重新绘制

protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

actionBar.AddView(mainActionBar);
formDialog.AddView(LayoutInflater.Inflate(Resource.Layout.googleGraphInWebview, null));

formDialog.SetMinimumHeight(400);

graph = FindViewById<WebView>(Resource.Id.graphView);
list = FindViewById<ListView>(Resource.Id.AppointmentList); // get reference to the ListView in the layout

appointments.Add(new AppointmentListItem("Appointment: Appointment with Spur Cresta", "Remember to meet with Mike regarding the cost sales!", Resource.Drawable.Icon));
appointments.Add(new AppointmentListItem("Appointment: Jone's laundry needs to be collected", "Address: 12 Marry Street Roodepoort", Resource.Drawable.Icon));

list.Adapter = new AppointmentListViewAdapter(this, appointments);
list.ItemClick += AppointmentListClick; // to be defined

LinearLayout sideWidget = FindViewById<LinearLayout>(Resource.Id.SideWidget);
sideWidget = FindViewById<LinearLayout>(Resource.Id.SideWidget);
sideWidget.AddView(LayoutInflater.Inflate(Resource.Layout.LineItem, null));

graph.Settings.JavaScriptEnabled = true;
graph.SetWebViewClient(new webView(formDialog));
graph.LoadUrl("file:///android_asset/graph.html");

}

你能帮忙吗?

一个

最佳答案

所以真正的问题是我不仅需要做上述所有事情,还需要特别添加

graph.SetWebChromeClient(new WebChromeClient());
graph.SetWebViewClient(new webView(formDialog));

SetWebChromeClient(new WebChromeClient()); 非常重要。

添加此行后,每次都会加载页面。瞬间

一个

关于android - Webview 不是每次都加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15442550/

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