Back to project page androidui.
The source code is released under:
MIT License
If you think the Android project androidui listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package course.examples.UI.WebView; //from w ww . j av a2s . co m import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebViewActivity extends Activity { public static final String URL = "http://www.pearsonhighered.com"; private static final String TAG = "WebViewActivity"; private WebView mWebView; @SuppressLint("SetJavaScriptEnabled") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); // Set a kind of listener on the WebView so the WebView can intercept // URL loading requests if it wants to mWebView.setWebViewClient(new HelloWebViewClient()); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(true); mWebView.getSettings().setDisplayZoomControls(true); mWebView.loadUrl(URL); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { mWebView.goBack(); return true; } return super.onKeyDown(keyCode, event); } private class HelloWebViewClient extends WebViewClient { // Give application a chance to catch additional URL loading requests @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.i(TAG, "About to load:" + url); view.loadUrl(url); return true; } } }