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://lesapplication.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
0 Response to "More on WebView, override url loading"
Posting Komentar