title: ImageAdapter cannot be applied to a Fragment Class
body: <p>I am trying to follow ImageView and GalleryView tutorial and add a galleryview in a fragment class however there is an error that the ImageAdapter cannot be applied to the Tab1Fragment class, and I cannot figure out how to solve it.</p>
  
  <p><img src="https://i.stack.imgur.com/L1ubZ.png" alt="enter image description here"></p>
  
  <p><strong>Fragment Class</strong></p>
  
  <pre><code>package eu.lucazanini;
  
  import android.app.Activity;
  import android.app.Fragment;
  import android.content.Context;
  import android.content.Intent;
  import android.net.Uri;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.GridView;
  import android.widget.Toast;
  
  import eu.lucazanini.DialogHelper;
  
  
  public class Tab2Fragment extends Fragment{
  
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          return inflater.inflate(R.layout.tab2, container, false);
  
          GridView gridview = (GridView) gridview.findViewById(R.id.gridview);
          gridview.setAdapter(new ImageAdapter(this);
  
          gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                                      int position, long id) {
                  Toast.makeText(getActivity(), "" + position,
                          Toast.LENGTH_SHORT).show();
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>ImageAdapter Class</strong> - No errors shown within this class, only within the Fragment Class</p>
  
  <pre><code>package eu.lucazanini;
  
  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 };
  }
  </code></pre>