Thursday, August 27, 2009

WebView in Android :

Web View In Android :

WebViewclassOverview click here to see the webview class details .

Here i am pasting the small example over webview implementation


package com.vinnysoft.webkit;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.FrameLayout;

public class WebSample extends Activity {
/** Called when the activity is first created. */
private static final FrameLayout.LayoutParams ZOOM_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
private WebView wv;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.setContentView(R.layout.main);
this.wv = (WebView) this.findViewById(R.id.webview);

FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = this.wv.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);

this.wv.loadUrl("http://imageurl.com/1.jpg");

// for example this.wv.loadUrl("http://news.softpedia.com/newsImage/RIM-Announces-BlackBerry-JDE-Plug-in-for-Eclipse-3.JPG");

like this example ....



}
}

In the res folder make the layout like this create a webview widget over there


android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>


No comments:

Post a Comment