Package Name : selva.web
Project Name : WebView2
Version : 1.5 ( Supports 1.5 and above versions)
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<WebView android:id="@+id/webview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<WebView android:id="@+id/webview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Create ex.html under assets folder
<body>
<h1> Hi This is Simple Website </h1>
<a href="http://www.androidprogramz.in/"> Click Here </a>
</body>
<h1> Hi This is Simple Website </h1>
<a href="http://www.androidprogramz.in/"> Click Here </a>
</body>
WebView2Activity.java
package selva.web;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebView2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.webview1);
wv.loadUrl("file:///android_asset/ex.html");
}
}
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebView2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.webview1);
wv.loadUrl("file:///android_asset/ex.html");
}
}
OUTPUT:
Click Here to Download Source Code
Thanks for the source code . i'm trying to build an android app for my education site tnpsc exams
ReplyDeleteThanks for this code .
ReplyDeleteYou are welcome..!
ReplyDelete