title: How to set background into Android Gridview?
body: <p>i need to set image as background in android gridview. I have code which is using image view to load images. Following codes are my codes, please help me out to solve this issue.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
  
      if(!isNetworkAvailbale()){
          Toast.makeText(getApplicationContext(), "Internet Connection not available", Toast.LENGTH_SHORT).show();
          finish();
      }
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.gridview);
  
      GridView gridview = (GridView) findViewById(R.id.gridview);
      gridview.setAdapter(new ImageAdapter(this));
  
      gridview.setOnItemClickListener(new OnItemClickListener() {
  
          public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
              Log.d("taust","sds");
              Toast.makeText(NuesHoundRSSActivity.this, "Item co" + position, Toast.LENGTH_SHORT).show();
          }
      });
  
  }
  </code></pre>
  
  <p>ImageAdapter</p>
  
  <pre><code>package com.nues.rss;
  
  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(150, 150));
          imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
          imageView.setPadding(1, 1, 1, 1);
      } else {
          imageView = (ImageView) convertView;
      }
  
      imageView.setImageResource(mThumbIds[position]);
     // imageView.setTag(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>
  
  <p>Any body knows how to set images as background of grid items ?</p>