title: screen rotation and live update gridview android
body: <p>i have a big doubt about memory leak and screen rotation. I know that activity is destroy when that happens and new one is started. With my code, with is the best way to show the gridview? (this activity is part of a tab activity so in the main one i get the pictures from web services and put them on the object, using AsyncTask)</p>
  
  <p>i would like to show the pictures at the same time they are saved on the object. Like simulating ajax...is that possible? at the moment, they are all show on the start or resume.</p>
  
  <p>Also, im facing memory leak here?</p>
  
  <p>last question, how can i show photos in the grid </p>
  
  <p>my code:</p>
  
  <pre><code>public class LoteFotosActivity extends Activity {
  
  Sistema sis=Sistema.getInstance();
  
  Lote lote;
  GridView gridview;
  ImageAdapter iA;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.lote_foto_view);
      Bundle extras = getIntent().getExtras();
      lote=sis.getLoteDetalle(extras.getInt("LoteID"));
  
      gridview = (GridView) findViewById(R.id.gridview);
      gridview.setAdapter(iA=new ImageAdapter(this));
  
      gridview.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
              Toast.makeText(LoteFotosActivity.this, "" + position, Toast.LENGTH_SHORT).show();
          }
      });
  
  }
  
  public class ImageAdapter extends BaseAdapter {
      private Context mContext;
  
      public ImageAdapter(Context c) {
          mContext = c;
      }
  
      public int getCount() {
          return lote.FOTOS.size();
      }
  
      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(200,200));
              imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
              imageView.setPadding(8, 8, 8, 8);
          } else {
              imageView = (ImageView) convertView;
          }
  
          imageView.setImageBitmap(lote.FOTOS.get(position));
          return imageView;
      }
  
  }
  //test looking
  public void onResume() { 
      super.onResume();
      Toast.makeText(this,"ON RESUME",
              Toast.LENGTH_SHORT).show(); 
  //  gridview.setAdapter(new ImageAdapter(this));
  //  foto.setImageDrawable(lote.FOTOS.get(0));
  }
  public void onPause() { 
      super.onPause();
      Toast.makeText(this,"onPause",
              Toast.LENGTH_SHORT).show(); 
      iA=null;
      gridview.setAdapter(iA=new ImageAdapter(this));
  //  foto.setImageDrawable(lote.FOTOS.get(0));
  }
  </code></pre>
  
  <p>thx in advance !</p>