2013-03-15 60 views
2

我有一個Webview,它必須從assets文件夾中加載一個靜態網頁。該網頁包含一個完美的JavaScript功能。問題是,每當活動啓動時,網頁永遠不會出現(並且通常是這樣,而且啓動活動包含web視圖),所以經常出現 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"); 

} 

你能幫忙嗎?

一個

+2

移動'LoadUrl'到'OnResume'也許? – 2013-03-15 21:57:09

回答

0

所以,真正的問題是,我不僅需要做到以上,但具體添加

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

SetWebChromeClient(新WebChromeClient());是非常重要的。

我添加了這一行後,每次加載頁面。瞬間

A