Image show in full screen mode
<p>I have created an app in which images are showing on the gridview, I want when I click on a particular image it show on full screen on the next page.</p>

<p>I have write down code, but when I am clicking on the image,it is crashing.</p>

<p>Please somebody help me</p>

<pre><code>public class GridViewActivity extends Activity {        

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(this));

        gridview.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {

                long imageId = (Long) parent.getAdapter().getItem(position);

                Intent fullScreenIntent = new Intent(v.getContext(),FullScreenImage.class);

                fullScreenIntent.putExtra("Hello",imageId); 

                startActivity(fullScreenIntent); 

            }
        });


       /* gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
                Toast.makeText(GridViewActivity.this, "" + position, Toast.LENGTH_SHORT).show();
            }
        });*/
    }

    public class ImageAdapter extends BaseAdapter {
        private Context mContext;

        public ImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return images.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        // create a new ImageView for each item referenced by the Adapter

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {  // if it's not recycled, initialize some attributes
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView.setPadding(8, 8, 8, 8);
            } else {
                imageView = (ImageView) convertView;
            }

            imageView.setImageResource(images[position]);
            return imageView;
        }

        // references to our images
        private Integer[] images = {
                R.drawable.bluehills, R.drawable.sample_3,
                R.drawable.sample_7, R.drawable.sunset,
                R.drawable.waterlilies, R.drawable.winter,  

        };
    }
}
</code></pre>
