我想使用window.loadUrl("Javascript:window.location.reload(true)"); 重新加载 webview 但无法执行。我可以得到一些建议或替代解决方案吗?我只是想让按钮重新加载以重新加载 webview窗口
谢谢,下面的Java:
package com.fortunecaster.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
public class FcastActivity extends Activity {
WebView window;
Button reload;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fcast);
window = (WebView)findViewById(R.id.webView1);
window.getSettings().setJavaScriptEnabled(true);
window.getSettings().setLoadWithOverviewMode(true);
window.getSettings().setUseWideViewPort(true);
window.setWebViewClient(new WebViewClient());
window.setWebChromeClient(new WebChromeClient());
window.getSettings().setAppCacheEnabled(true);
try {
window.loadUrl("http://www.fortunecaster.com/android-td");
} catch (Exception e) {
e.printStackTrace();
//setup button
reload = (Button)findViewById(R.id.button1);
//set onClickListener
reload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
window.loadUrl("Javascript:window.location.reload( true )");
// TODO Auto-generated method stub
}
});
}
}