Making image full screen on android tutorial app

前端 未结 2 1235
陌清茗
陌清茗 2020-12-30 12:22

Using the Hello, World Gridview tutorial example, I am attempting to make the image fullscreen on click instead of display the position of the image in the array. As I am u

2条回答
  •  暖寄归人
    2020-12-30 12:53

    Here, you're taking the ID of the view that was clicked (passed in the view argument) and using it to look up itself again:

    ImageView imgView = (ImageView) findViewById(view.getId()); 
    

    That makes no sense, especially since the clicked view apparently has no ID, causing findViewById to return null.

    You probably want to pass the ID of your ImageView instead:

    ImageView imgView = (ImageView) findViewById(R.id.whatever_the_id_of_the_image_view_is);
    

提交回复
热议问题