Android webView is
used to display web page in android. The web page can be loaded from same application
or URL.Android webView uses webkit engine to display web page.The android.webkit.WebView is the subclass of AbsoluteLayout class.
The loadUrl() and loadData() methods of Android WebView class are used
to load and display web page.
activity_main.xml
.................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Android Beginner tutorials"
android:textSize="12dp" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp" />
</LinearLayout>
MainActivity.java
..................................................................................................................................................
package com.androidbeginnerpoint.testapplication;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
@SuppressLint("NewApi")
public class MainActivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setTitle(" WebView tutorial");
setContentView(R.layout.activity_main);
WebView mywebview = (WebView) findViewById(R.id.webView1);
mywebview.loadUrl("http://androidbeginnerpoint.blogspot.in/");
}
}
0 comments