Javascript 安卓网络视图

Javascript 安卓网络视图,javascript,android,webview,Javascript,Android,Webview,请参考本教程,特别是此方法 private void setupWebView(){ String MAP_URL = "http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html"; String centerURL = "javascript:centerAt(" + mostRecentLocation.getLatitude() + ","+ m

请参考本教程,特别是此方法

private void setupWebView(){
    String MAP_URL = "http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html";
    String centerURL = "javascript:centerAt(" + mostRecentLocation.getLatitude() + ","+ mostRecentLocation.getLongitude()+ ")";
    webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    //Wait for the page to load then send the location information
    webView.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url){
            webView.loadUrl(centerURL);
        }
    });
    webView.loadUrl(MAP_URL);
}
我注意到,如果我放置
webView.loadUrl(centerURL)直接在后面
webView.loadUrl(映射URL)像这样

private void setupWebView(){
    String MAP_URL = "http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html";
    String centerURL = "javascript:centerAt(" + mostRecentLocation.getLatitude() + "," + mostRecentLocation.getLongitude()+ ")";
    webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    //Wait for the page to load then send the location information
    webView.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url){
            //DO NOTHING
        }
    });
    webView.loadUrl(MAP_URL);
    webView.loadUrl(centerURL);
}
它不再起作用了。因此
centreAt(…)
javascript方法包含在
MAP\uurl

我想知道
webView.loadUrl(..)
方法是否在url实际加载之前返回。 看起来是这样的,因为top方法在运行javascript之前等待它完全加载。是的,
webView.loadUrl()
是异步的:它立即返回,webView在自己的线程中继续工作

要监视WebView页面加载,请使用:


呻吟。。。。我浪费了一整天才发现这一点。哦,好吧。为确认彼得的身份干杯。
webview.setWebViewClient(new WebViewClient() {
    public void onPageFinished(WebView view, String url) {
        // do something here
    }
});