Passing an image to a dialog box
<p>I am trying to create a custom dialog box that displays an image in full-view and has a Select as well as Cancel Button. This custom dialog box should be displayed when an image is clicked so as to allow the user to view the selected image in full-view. The image view should be one that is selected from a GridView. The Select Button will display a Toast message and the Cancel button will allow the user to exit the dialog. The idea is to allow the user to see the image in full-view before he or she makes a final choice on the picture they would like.</p>

<p>However, I can't figure out how to pass the chosen image to the dialog box so that it can be displayed. I would also like to know if it is possible to make the dialog box fill the entire screen on the phone. My code and the errors are shown below:</p>

<pre><code>    import android.app.Activity;
    import android.app.Dialog;    
    import android.content.Context;
    //import android.content.Context;
    import android.os.Bundle; import android.view.View;
    //import android.view.ViewGroup;
    import android.widget.AdapterView;
    //import android.widget.BaseAdapter;
    import android.widget.GridView;
    //import android.widget.ImageView;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemClickListener;
    import android.view.View.OnClickListener;
    import android.view.View;

    public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); setContentView(R.layout.main);

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

        gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView&lt;?&gt; parent, View v, final int position, long id) {

                Context mContext = getApplicationContext();
                final Dialog dialog = new Dialog(mContext);

                dialog.setContentView(R.layout.ImageDialog);
                dialog.setTitle("Full-image view");

                ImageView image = (ImageView) dialog.findViewById(R.id.image);
                image.setImageResource(R.drawable.android);

                Button select = (Button) dialog.findViewById(R.id.selectimage);
                select.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {

                    Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();


                    }
                }); 

                Button cancel = (Button) dialog.findViewById(R.id.cancelselection);
                cancel.setOnClickListener(new OnClickListener() 
               //error here: Syntax error on tokens;AnnotationName expected instead { public void onClick(View v) { dialog.cancel();

                    }
                });

            }
            dialog.show(); 
           // error here: Syntax error on token "show", Identifier expected after this          
           //token 
        });
    }




    import android.content.Context;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.GridView;
    import android.widget.ImageView;

    public class ImageAdapter extends BaseAdapter{

    private Context mContext;

    public ImageAdapter(Context c) {
        mContext = c;
    }

    public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

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

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }

    // references to our images
    private Integer[] mThumbIds = {

            R.drawable.sample_2, R.drawable.sample_3,
            R.drawable.sample_4, R.drawable.sample_5,
            R.drawable.sample_6, R.drawable.sample_7,
            R.drawable.sample_0, R.drawable.sample_1,
            R.drawable.sample_2, R.drawable.sample_3,
            R.drawable.sample_4, R.drawable.sample_5,
            R.drawable.sample_6, R.drawable.sample_7,
            R.drawable.sample_0, R.drawable.sample_1,
            R.drawable.sample_2, R.drawable.sample_3,
            R.drawable.sample_4, R.drawable.sample_5,
            R.drawable.sample_6, R.drawable.sample_7,
            R.drawable.sample_0, R.drawable.sample_1,
            R.drawable.sample_2, R.drawable.sample_3,
            R.drawable.sample_4, R.drawable.sample_5,
            R.drawable.sample_6, R.drawable.sample_7,

    };
}
</code></pre>

<p>I also have problems with the token show, and I am also having trouble with the variable R. I have tried cleaning the project but that hasn't worked. Could some help with these problems? Any help would be much appreciated.</p>
