We provide complete mobile and web apps development solutions

Showing posts with label android webview loaddata. Show all posts
Showing posts with label android webview loaddata. Show all posts

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" />

Online Training

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

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts