Skip to content

Instantly share code, notes, and snippets.

@xperimental
Created January 6, 2010 23:57
Show Gist options
  • Save xperimental/270825 to your computer and use it in GitHub Desktop.
Save xperimental/270825 to your computer and use it in GitHub Desktop.
public class WebViewTest extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Set the Content View */
setContentView(R.layout.main);
/* Get the WebView */
WebView wv1 = (WebView) findViewById(R.id.wv1);
/* Activate JavaScript */
wv1.getSettings().setJavaScriptEnabled(true);
/* Prevent WebView from Opening the Browser */
wv1.setWebViewClient(new InsideWebViewClient());
}
/* Class that prevents opening the Browser */
private class InsideWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment