tags:

views:

35

answers:

1

Hi,

I have created an image gallery in android , now whenever i will click on image on a gallery then that particular image will get added into Grid View.

my layout has image gallery on top and image grid in bottom (so i have used LinerLayout Vertical )

so can anyone tell me how to achieve this in android ?

A: 
Gallery g = (Gallery) findViewById(R.id.gallery);    
g.setAdapter(new Gallerydapter(this));


g.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView parent, View v, int position, long id) {

ImageView imageView = new ImageView(PhotoGallery.this);
imageView.setLayoutParams(new GridView.LayoutParams(45, 45));
imageView.setAdjustViewBounds(false);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
imageView.setImageResource(mImageIds[position]);

mGrid.addView(imageView);

}

I have used the above code to add images in grid view , is this the efficient code ? i mean is this code gonna generate running out of memory error

Hunt