We provide complete mobile and web apps development solutions

Monday, April 29, 2013

WebView in Android

WebView displays web pages.

package com.example.webview;

import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends Activity {
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView1);
     WebSettings webSettings = webView.getSettings();

        webSettings.setJavaScriptEnabled(true);
webView.loadUrl("http://www.mobengineers.com");
   
}

}



activity_main.xml


<RelativeLayout 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"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true" />

</RelativeLayout>

Declare permission in manifest for internet access.

<uses-permission android:name="android.permission.INTERNET" />

0 coment�rios:

Post a Comment

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts