Sunday, October 4, 2015

Android webView Tutorial

Basic app the opens a webView.

Main.java
webView = (WebView) findViewById(R.id.webview);webView.getSettings().setJavaScriptEnabled(true);webView.setWebViewClient(new MyBrowser());webView.loadUrl("https://github.com/login");

activity_main.xml
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/webview"    android:layout_marginTop="60dp"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:focusable="true"  />

Add Internet permission to Manifest.
<uses-permission android:name="android.permission.INTERNET" />

Done :-)

Download code here: https://github.com/AndreSand/NoteGit

No comments:

Post a Comment