First of all make an xml file and put the following code here.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView android:id="@+id/wv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Now make an java file and enter the following code here.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String myURL = "http://typicaljava.blogspot.com";
WebView browser=(WebView)findViewById(R.id.mybrowser);
browser.getSettings().setJavaScriptEnabled(true);
browser.loadUrl(myURL);
}
}
We just need to add the permission in the menifest file.
<uses-permission android:name="android.permission.INTERNET" />
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.