I have written a app, and I have pictures which are stored in the /
drawable directory.  My app makes a sliding gallery across the top,
(id gallery1) and as you select the picture in the gallery it load
the
picture bigger underneath, (id image1). These a layed out in a XML
file.  There is a button below the image (image1) which is called (id
mybutton).
I want it when a image comes up, when the button is pressed it loads
the same image on a XML layout file, in which the picture is full
screen, the ID of the XML file image is (id bigpic), and then from
there to beable to press the back button to go back to the gallery
screen.  Can anyone help?


My Whole Code is:


***************************************************************************­
******************
public class PicViews extends Activity
{
    //---the images to display---
    Integer[] imageIDs = {
            R.drawable.pic01,
            R.drawable.pic02,
            R.drawable.pic03,
            R.drawable.pic04,
            R.drawable.pic05


    };


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.displayview);


        Gallery gallery = (Gallery) findViewById(R.id.gallery1);


        gallery.setAdapter(new ImageAdapter(this));
        gallery.setOnItemClickListener(new OnItemClickListener()
        {
                 public void onItemClick(AdapterView parent,
                            View v, int position, long id)
                            {
                                //---display the images selected---
                                ImageView imageView = (ImageView)
findViewById(R.id.image1);


imageView.setImageResource(imageIDs[position]);
                            }
        });
    }


    public class ImageAdapter extends BaseAdapter
    {
        private Context context;
        private int itemBackground;


        public ImageAdapter(Context c)
        {
            context = c;
            //---setting the style---
            TypedArray a =
obtainStyledAttributes(R.styleable.Gallery1);
            itemBackground = a.getResourceId(
                R.styleable.Gallery1_android_galleryItemBackground,
0);
            a.recycle();
        }


        //---returns the number of images---
        public int getCount() {
            return imageIDs.length;
        }


        //---returns the ID of an item---
        public Object getItem(int position) {
            return position;
        }


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


        //---returns an ImageView view---
        public View getView(int position, View convertView, ViewGroup
parent) {
            ImageView imageView = new ImageView(context);
            imageView.setImageResource(imageIDs[position]);
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
            imageView.setLayoutParams(new Gallery.LayoutParams(150,
120));
            imageView.setBackgroundResource(itemBackground);
            return imageView;
        }
    }



}


***************************************************************************­
******************

The Section of code which pulls up the image and makes the bigger
picture show is:


***************************************************************************­
******************
 gallery.setOnItemClickListener(new OnItemClickListener()
        {
                 public void onItemClick(AdapterView parent,
                            View v, int position, long id)
                            {
                                //---display the images selected---
                                ImageView imageView = (ImageView)
findViewById(R.id.image1);


imageView.setImageResource(imageIDs[position]);
                            }
        });
***************************************************************************­
*******************




Please help, I'm only learning.


-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to