package com.example.gridview;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class ImageGridView extends AppCompatActivity {

    private ImageAdapter myImgAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_view);

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

        gridview.setOnItemClickListener((parent, v, position, id) -> {
            LayoutInflater inflater = getLayoutInflater();
            View view = inflater.inflate(R.layout.toast_layout,
                    (ViewGroup) findViewById(R.id.relativeLayout1));
            view.setBackgroundResource(myImgAdapter.getImgID(position));

            Toast toast = new Toast(parent.getContext());
            toast.setView(view);
            toast.show();
        });
    }
}

@@ -116,39 +116,8 @@
 ew;%0A
-import android.view.ViewGroup;%0A
 impo
@@ -558,19 +558,8 @@
 ew =
- (GridView)
  fin
@@ -845,20 +845,8 @@
     
- (ViewGroup)
  fin

Remove unneeded casts.