title: Change GridView images on item click at run time in android
body: <p>i am using GridView in application. and i wants that when i click on item it should replace on another array picture. actually i used two array when application run first time, the GridView  will show the first array picture , after that when i  click  on item it should replace by the  second array picture according to its position.<br>
  i did try but did't solve. so any one help me..  </p>
  
  <p>GridViewContent.java    </p>
  
  <pre><code>public class GridViewContent extends BaseAdapter {
      private Context context;
  
      public int pictureArray[]={
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,
              R.drawable.question,        
      };
      public GridViewContent(Context c){
          context=c;
  
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return (pictureArray.length);
      }
  
      @Override
      public Object getItem(int position) {
          // TODO Auto-generated method stub
          return pictureArray[position];
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return 0;
      }
  
      @Override
      public View getView(int position, View arg1, ViewGroup arg2) {
          // TODO Auto-generated method stub
          ImageView myimage=new ImageView(context);
          myimage.setImageResource(pictureArray[position]);
          myimage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
          myimage.setLayoutParams(new GridView.LayoutParams(70, 70));
  
  
          return myimage;
      }
  
  }      
  </code></pre>
  
  <p>MainActivity.java     </p>
  
  <pre><code>public class MainActivity extends Activity {
      Context ctx;
      GridViewContent grid1 = new GridViewContent(ctx);
      // GridView grid;
      /*
       * static final int[] numbers = new int[] {
       * R.drawable.question,R.drawable.question
       * ,R.drawable.question,R.drawable.question
       * ,R.drawable.question,R.drawable.question, R.drawable.question,
       * 
       * };
       */
      public int OriginalArray[] = { 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, };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          final GridView grid = (GridView) findViewById(R.id.gv_memory);
          grid.setAdapter(new GridViewContent(this));
          // grid.setOnItemClickListener(itemClickListener);
          grid.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  int id = v.getId();
                  ImageView pictImage = new ImageView(ctx);
                  int imgView = OriginalArray[id];
                  pictImage.setImageResource(imgView);
  
              }
          });
  
      }
  }     
  </code></pre>
  
  <p>main.xml    </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/gv_memory"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:columnWidth="90dp"
      android:gravity="center"
      android:horizontalSpacing="10dp"
      android:numColumns="auto_fit"
      android:stretchMode="columnWidth"
      android:verticalSpacing="10dp" &gt;
  
  &lt;/GridView&gt;      
  </code></pre>
  
  <p>thanks in advance....</p>