In this application,by pressing a button we can retrieve a image from internet by giving a link to the application code.For this we need a xml layout containing a button and a imageview widget.When the button is pressed,the image data is retrieved and showed in the imageview widget.Here is the xml code of the layout:
Now look at the ImageReadMain class...
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Connect"></Button> <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> </LinearLayout>Now we will use three java class for this.In the first one named ImageReadMain ,we initialize the button and the imageview and define the onClick method of the button.In the second java class connection1 the code for connection is written in setNetwork() method.In the last one named Data class,we simply write a static bitmap variable,that we will use in previous two classes.
Now look at the ImageReadMain class...
package Image.Read.a; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView;