我在 Phonegap 应用程序中需要一点帮助。
我的申请中有一个CordovaWebView
。我需要从我的 html 中加载一个特定的页面(根据 jQuery Mobile 页面结构,它有多个页面),所以我这样使用loadUrl
:
cWebView.loadUrl("file:///android_asset/www/index.html#some-page-id");
这工作正常。我能看到some-page-id
。
现在我需要添加WebViewClient
for cWebView
。如果这样做,我会收到错误消息,并且 url 未加载到 webview 中。
代码:
cWebView.setWebViewClient(new MyCordovaWebViewClient(this, cWebView));
public class MyCordovaWebViewClient extends CordovaWebViewClient {
public MyCordovaWebViewClient(CordovaInterface cordova,
CordovaWebView view) {
super(cordova, view);
// TODO Auto-generated constructor stub
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
Log.d(TAG, "my page finished " + url);
super.onPageFinished(view, url);
}
}
错误:
Application Error: A network error occurred. (file:///android_asset/www/index.html#some-page-id)
如果我只是加载 index.html,而不提供特定的页面 id,那么我不会在setWebViewClient
.
任何setWebViewClient
与特定页面 ID 一起使用的解决方案?