我有一个Webview,它必须从assets文件夹加载静态网页。该网页包含一个完美的javascript函数。问题是每隔一段时间 当活动启动时,网页永远不会出现(通常也会出现。启动活动也包含webview)
当webview加载时,你导航到另一个活动然后回来,那时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");
}
你可以帮忙吗?
A
答案 0 :(得分:1)
所以真正的问题是我不仅要做以上所有事情,还要特别添加
graph.SetWebChromeClient(new WebChromeClient());
graph.SetWebViewClient(new webView(formDialog));
SetWebChromeClient(新的WebChromeClient()); 非常重要。
在我添加此行后,每次都会加载页面。瞬间
A