Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Android Example of Webview

Android Webview is used to load web page in Android application. The web page can be loaded in 2 ways which I will explain in the following code.

1. from same application
2. from URL.
It is used to display online content in android activity.

For this you have to give permission in AndroidManifest.xml

activity_main.xml

MainActivity.java

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
 
 
public class MainActivity extends Activity
{
	WebView w1;
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		w1=(WebView)findViewById(R.id.webView1);
		
		w1.loadUrl("http://google.com/");
	}
 
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
 
}

The post Android Example of Webview appeared first on Junaid Shahid | P-Blogger.



This post first appeared on Junaid Shahid | P-Blogger, please read the originial post: here

Share the post

Android Example of Webview

×

Subscribe to Junaid Shahid | P-blogger

Get updates delivered right to your inbox!

Thank you for your subscription

×