Open top menu


in this blog we will how to load webpage in android. its a very simple explain below

you can load webpage URL in WebView android wigets. show below code.

MainActivity.java,
.............................................................................................................................................................
package com.example.androidbeginnerpoin;

import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

@SuppressWarnings("deprecation")
public class MainActivity extends Activity {
private WebView mWebview ;
@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 mWebview  = (WebView)findViewById(R.id.webView1);
 mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript

      final Activity activity = this;

      mWebview.setWebViewClient(new WebViewClient() {
          public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
              Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
          }
      });

      mWebview .loadUrl("http://androidbeginnerpoint.blogspot.in/");
 

}

}



activity_main.xml.
.................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />







try this code.......



 

0 comments