我正在尝试编写一个应该显示地图的应用程序:
一切正常,但它不显示地图。我在我的应用程序中启用了 Javascript 和任何东西,但它不起作用。你能看一下吗?
package com.timbremer.iimv;
import android.content.Context;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends ActionBarActivity {
private WebView wv;
private EditText etlocation;
private Button btclose;
private Button btgo;
private boolean send;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
send = false;
WebView wv = (WebView) findViewById(R.id.wv);
wv.getSettings().setBuiltInZoomControls(true);
CookieManager.getInstance().setAcceptCookie(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.loadUrl("http://www.ingress.com/intel");
wv.getSettings().setGeolocationEnabled(true);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setAppCacheEnabled(true);
etlocation = (EditText) findViewById(R.id.etlocation);
Button btgo = (Button) findViewById(R.id.btgo);
btgo.setOnClickListener(new View.OnClickListener() {
private String location;
@Override
public void onClick(View v) {
location = etlocation.getText().toString();
WebView wv = (WebView) findViewById(R.id.wv);
wv.getSettings().setBuiltInZoomControls(true);
CookieManager.getInstance().setAcceptCookie(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setGeolocationEnabled(true);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setAppCacheEnabled(true);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if(!send) {
view.loadUrl("javascript:{" +
"document.getElementById('adress').value='" + location + "';" +
"var form = document.getElementsByName('login');" +
"form[0].submit();};"
);
send = true;
}
}
});
}
});
}
}
谢谢!