WebViewロードプログレスバー、WebViewリターンキー書き換えメカニズム
1、画像の遅延ロード
2、ロードプログレスバー表示
3、戻りキー書き換え
brower = (WebView) this.findViewById(R.id.brower);
settings = brower.getSettings();
settings.setJavaScriptEnabled(true);
//
settings.setBlockNetworkImage(true);
private class Client extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// TODO Auto-generated method stub
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url)
{
// TODO Auto-generated method stub
super.onPageFinished(view, url);
view.getSettings().setBlockNetworkImage(false);
}
}
2、ロードプログレスバー表示
private class ChromeView extends WebChromeClient
{
@Override
public void onProgressChanged(WebView view, int newProgress)
{
// TODO Auto-generated method stub
super.onProgressChanged(view, newProgress);
if (newProgress == 100) {
progressbar.setVisibility(GONE);
} else {
if (progressbar.getVisibility() == GONE)
progressbar.setVisibility(VISIBLE);
progressbar.setProgress(newProgress);
}
}
3、戻りキー書き換え
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) { mWebView.goBack();// return true; } return super.onKeyDown(keyCode, event); }
}