We have to call setWebViewClient() to set our WebViewClient to receive various notifications and requests.
package com.AndroidWebView;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class AndroidWebViewActivity extends Activity {
WebView webView;
final String DEFAULT_URL = "http://android-coding.blogspot.com/?m=1";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView)findViewById(R.id.webview);
webView.setWebViewClient(new MyWebViewClient());
webView.loadUrl(DEFAULT_URL);
}
public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
}
}
next:
- Enable JavaScript and built-in zoom control of WebView
when you load a html file, sometime it goes so slow. How can you make it smoothe or faster load.?
ReplyDeleteThanks in advance.
Thanks.. Was very helpful.
ReplyDelete