Tuesday, January 15, 2013

How to Draw a Image on Android

Hello friends Its very use full code for you when you are starting learner in android tutorial. Because you  never start without How to draw a image on android.

First you create a project Camera testing in Eclipse

Go to file section and click on New Android Project


And fill the section.

Then work on activity.xml.

<?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" >

   <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />

<ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />

<ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />

<ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />



</LinearLayout>/


Now you come on the his MainActivity. just simple click on his main activity and to call image on onCreate activity and simple you are done your first project in android.

  package com.example.image
import android.app.Activity;
import android.widget.ImageView;


public class MainActivity extends Activity 
 {
    ImageView[] ivImage = new ImageView[4];



@Override
protected void onCreate(Bundle savedInstanceState) 
{
           ivImage[0]=(ImageView)findViewById(R.id.imageView1);
   ivImage[1]=(ImageView)findViewById(R.id.imageView2);
   ivImage[2]=(ImageView)findViewById(R.id.imageView3);
   ivImage[3]=(ImageView)findViewById(R.id.imageView4);
}


@Override

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

  }