title: How to: gridview inside a fragment?
body: <p>I want to create a gridview like android market, I want to populate this with images from a database on internet. it need to work with androidv4.support, since I want to run 2.2 until 4.0.</p>
  
  <p>Someone said, that isnt possible to create a gridview in pre-4.0, is it true?</p>
  
  <p>However It only works when I put use <code>setListAdapter()</code>, but it shows only one image per line, like a listview, when I change to <code>gridview.setAdapter()</code>, it doenst work anymore.</p>
  
  <p>Here is my try:</p>
  
  <p>This is the ListFragment class:</p>
  
  <pre><code> public static class ArrayListFragment extends ListFragment implements OnScrollListener{
  
          ImageAdapter adapter = new ImageAdapter();
  
          @Override
          public void onActivityCreated(Bundle savedInstanceState) {
              super.onActivityCreated(savedInstanceState);
  
  
                  LayoutInflater gridInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  View v = gridInflater.inflate(R.layout.imagelist, null);
                  GridView gridView = (GridView) v.findViewById(R.id.list);
  
  
  
  
              ImageDownloader.Mode mode = ImageDownloader.Mode.CORRECT;
  //            ImageAdapter imageAdapter = new ImageAdapter();
              adapter.getImageDownloader().setMode(mode);
              setListAdapter(adapter); 
  //            gridView.setAdapter(adapter);
              getListView().setOnScrollListener(this);
  
          }
  </code></pre>
  
  <p>This is ImageAdapter class:</p>
  
  <pre><code>    public class ImageAdapter extends BaseAdapter {
  
              private Context mContext;
  
          private final ImageDownloader imageDownloader = new ImageDownloader();
  
              public static int count = 10;
  
  private final String[] URLS = {
          "http://lh5.ggpht.com/_mrb7w4gF8Ds/TCpetKSqM1I/AAAAAAAAD2c/Qef6Gsqf12Y/s144-c/_DSC4374%20copy.jpg",
          "http://lh5.ggpht.com/_Z6tbBnE-swM/TB0CryLkiLI/AAAAAAAAVSo/n6B78hsDUz4/s144-c/_DSC3454.jpg",
          "http://lh3.ggpht.com/_GEnSvSHk4iE/TDSfmyCfn0I/AAAAAAAAF8Y/cqmhEoxbwys/s144-c/_MG_3675.jpg",
          "http://lh6.ggpht.com/_Nsxc889y6hY/TBp7jfx-cgI/AAAAAAAAHAg/Rr7jX44r2Gc/s144-c/IMGP9775a.jpg",
          "http://lh3.ggpht.com/_lLj6go_T1CQ/TCD8PW09KBI/AAAAAAAAQdc/AqmOJ7eg5ig/s144-c/Juvenile%20Gannet%20despute.jpg",
          };
  
              public int getCount() {
                  return count;
              }
  
              public String getItem(int position) {
                  return URLS[position];
              }
  
              public long getItemId(int position) {
                  return URLS[position].hashCode();
              }
           public View getView(int position, View convertView, ViewGroup parent) {
                  View v;
  
                  if (convertView == null) {
                      v = LayoutInflater.from(mContext).inflate(R.layout.image_text_view,null);
                      v.setLayoutParams(new GridView.LayoutParams(200,200));
  
                      ImageView imageview = (ImageView)v.findViewById(R.id.image);
                      imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
                      imageview.setPadding(6, 6, 6, 6);
                      imageDownloader.download(URLS[position], imageview);
                  }
               else {
                  v = convertView;
              }
  
                  return v;
              }
  
              public ImageDownloader getImageDownloader() {
                  return imageDownloader;
              }
      }
  </code></pre>
  
  <p>It could help a lot if anyone have a sample. Thanks</p>