【发布时间】:2015-03-22 06:43:30
【问题描述】:
如何在 webview 中再次加载 failedUrl ??
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.webView); //webview in activity_main.xml
[....] // some other codes
web.loadUrl("http://my-example-site.com");
[....] // some other codes
}
// if no network, then show error.xml with a reload button;
@Override
public void onReceivedError(final WebView view, int errorCode, String description, final String failingUrl){
setContentView(R.layout.error);
button = (Button) findViewById(R.id.button1); // Reload Button in error.xml
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
web.loadUrl(failingUrl); //this one is not working...
}
});
}
我想再次加载 failedUrl..
【问题讨论】: