How to display clicked image from a set of images from a linear layout?
<p>i got images from SD card folder and added them to LinearLayout dynamically which is inside a HorizontalScrollview.now when i click an image i want to show that particular image in another ImageView in the same activity as big image. how can i do that? i tried by getting getId(),getTag() but i am unable to do, please give me suggestions. 
Note:I dont want use gallery widget because of center-locking feature.
My code :</p>

<pre><code>    package com.pop.cam;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;

    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.view.View;
    import android.view.ViewGroup.LayoutParams;
    import android.widget.ImageView;
    import android.widget.LinearLayout;

    public class GalleryView extends Activity {

        ImageView iv;
        File[] sdDirFiles;
        LinearLayout linearLayout;
        int i;
        String path;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
            setContentView(R.layout.pictures);
            linearLayout = (LinearLayout) findViewById(R.id.linearView);
            iv = (ImageView) findViewById(R.id.ImageView);

            // getting images from SD card folder
            File sdDir = new File("/sdcard/Pictures/"
                    + MyCameraAppActivity.DIR_NAME);
            sdDirFiles = sdDir.listFiles();
            for (i = 0; i &lt; sdDirFiles.length; i++) {
                final ImageView imageView = new ImageView(this);
                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                imageView.setLayoutParams(new LayoutParams(130, 100));
                Bitmap b = decodeFile(sdDirFiles[i].getAbsoluteFile());
                imageView.setImageBitmap(b);
                path = sdDirFiles[i].getAbsolutePath();
                imageView.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // Here i want to set clicked image as big.
                                        //I tried following but not workin
                        iv.setImageResource(v.getId());
                                        iv.setImageURI(Uri.parse(path));
Bitmap b = decodeFile(sdDirFiles[Integer.valueOf(v.getId())].getAbsoluteFile());
                    iv.setImageBitmap(b);

                    }
                });
                linearLayout.addView(imageView);
            }
        }

        // decodes image and scales it to reduce memory consumption
        private Bitmap decodeFile(File f) {
            try {
                // Decode image size
                BitmapFactory.Options o = new BitmapFactory.Options();
                o.inJustDecodeBounds = true;
                BitmapFactory.decodeStream(new FileInputStream(f), null, o);

                // The new size we want to scale to
                final int REQUIRED_SIZE = 70;

                // Find the correct scale value. It should be the power of 2.
                int scale = 1;
                while (o.outWidth / scale / 2 &gt;= REQUIRED_SIZE
                        &amp;&amp; o.outHeight / scale / 2 &gt;= REQUIRED_SIZE)
                    scale *= 2;

                // Decode with inSampleSize
                BitmapFactory.Options o2 = new BitmapFactory.Options();
                o2.inSampleSize = scale;
                return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
            } catch (FileNotFoundException e) {
            }
            return null;
        }
    }
</code></pre>

<p>pictures.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;HorizontalScrollView
        android:id="@+id/horizontalScorllView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" &gt;

        &lt;LinearLayout
            android:id="@+id/linearView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;
        &lt;/LinearLayout&gt;
    &lt;/HorizontalScrollView&gt;

    &lt;ImageView
        android:id="@+id/ImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:contentDescription="@string/app_name" &gt;
    &lt;/ImageView&gt;

&lt;/LinearLayout&gt;
</code></pre>
