2

When I'm loading a page using .loadData or .loadDataWithBaseURL, the system will load a page once.

After that, subsequent calls do not work.

In 4.0.3, if I were to call the function a second time with new data, it does change.

How can I fix this for 2.2+? Do I destroy the webview and create a new one?

webView1.loadDataWithBaseURL("file://", page, "text/html", "UTF-8", null);
webView1.loadUrl( "javascript:window.location.reload( true )" );
nhahtdh
  • 55,989
  • 15
  • 126
  • 162
mcollard
  • 161
  • 1
  • 12

2 Answers2

1

In loadDataWithBaseURL, set the last parameter to the URL where that data came from, instead of null.

theelfismike
  • 1,621
  • 12
  • 18
  • The page didn't come from anywhere... I'm using HTML generated programmatically. – mcollard Apr 19 '12 at 21:06
  • If you put something there, like "file://" (doesn't really matter), it will add that element to the history stack (when you click the back button), and you'll get a callback to shouldOverrideUrlLoading in your WebViewClient. – theelfismike Apr 19 '12 at 22:30
1

I think it should be "file:///". You just missed one slash.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Rubie
  • 11
  • 1