简体   繁体   中英

Android, GridView, Click an Image to show full size

I want to have a gridview where an image click displays the image full screen without creating a new activity. I have the grid set up.

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

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

        }
    });
}

i think i need to use setImageResource(R.drawable.?);

but im just kind of confused. any help would be great

Use a Dialog with an ImageView to show this image. You would have to create a separate layout for the dialog and set it.

If you don't want to create a new activity for that, a workaround could be to use an ViewFlipper and switch between the grid and an imageview when clicking on an image. Otherwise, I don't see any way to display something fullscreen with a gridview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM