简体   繁体   English

Android,GridView,单击图像以显示完整大小

[英]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. 我想要一个gridview,其中单击图像将全屏显示图像而不创建新活动。 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.?); 我认为我需要使用setImageResource(R.drawable。?);

but im just kind of confused. 但我只是有点困惑。 any help would be great 任何帮助都会很棒

Use a Dialog with an ImageView to show this image. 将对话框与ImageView一起使用以显示该图像。 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. 如果您不想为此创建新的活动,一种解决方法是在单击图像时使用ViewFlipper并在网格和imageview之间切换。 Otherwise, I don't see any way to display something fullscreen with a gridview. 否则,我看不到任何使用gridview全屏显示内容的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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