Displaying pictures in a gridview
<p>I am trying to display pictures that I had placed in the drawable folder using a Gridview. I am getting some errors. My code and the errors I am getting are shown below.</p>

<pre><code>package com.newapp;

import android.R;
import android.R.drawable;
import android.app.Activity;
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;/*Error here: main cannot be resolved or is not a field*/

import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

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);/*Error here: main cannot be resolved or is not a field*/

            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, int position, long id) {
                    Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();
                }
            });
        }


    }

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_0, /*Error here: sample_0 cannot be resolved and is not a field*/
            R.drawable.sample_1,/*Error here: sample_1 cannot be resolved and is not a field*/
            R.drawable.sample_2,/*Error here: sample_2 cannot be resolved and is not a field*/ 
           R.drawable.sample_3,/*Error here: sample_3 cannot be resolved and is not a field*/
            R.drawable.sample_4,/*Error here: sample_4 cannot be resolved and is not a field*/ 
           R.drawable.sample_5/*Error here: sample_5 cannot be resolved and is not a field*/,
            R.drawable.sample_6, 
           /*Error here: sample_6 cannot be resolved and is not a field*/
    };
}
</code></pre>

<p>So can somebody tell me what is causing these problems? Any help will be much appreciated.
Thanks in advance</p>
