Ø Create MainActivity.java class in src/package.
MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity {
private WebView webView1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView1 = (WebView) findViewById(R.id.webView1);
webView1.loadUrl("https://www.google.co.in/");
}
}
Ø Create main.xml in res/layout.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
Ø Add Permission in AndroidManifest.xml.
<uses-permission android:name="android.permission.INTERNET"
/>
No comments:
Post a Comment