title: iterate through all objects in gridview
body: <p>i am working on CrossWord application for Android.</p>
  
  <p>I have a gridview </p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private GridView gridView;
  private Button button;
  private ArrayAdapter&lt;String&gt; adapter;
  
  static final String[] numbers = new String[] { "A", "B", "C", "D", "E",
          "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
          "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E",
          "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
          "S", "T", "U", "V", "W", "X", "Y", "Z" };
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
      gridView = (GridView) findViewById(R.id.gridView1);
      button = (Button) findViewById(R.id.buttonSubmit);
  
      adapter = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_list_item_1, numbers);
  
      gridView.setAdapter(adapter);
  
      final StringBuilder sb = new StringBuilder();
  
      gridView.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                  int position, long id) {
                  TextView tv = (TextView) v;
                  tv.setBackgroundColor(Color.GREEN);
                  tv.setTag("1");
               Toast.makeText(getApplicationContext(),
               ((TextView) v).getText(), Toast.LENGTH_SHORT).show();            
          }
      });
  }
  
  public void onSubmitClick(View v){
      for(int i=0;i&lt;adapter.getCount();i++){
           String s = adapter.getItem(i);
      }
  }
  </code></pre>
  
  <p>xml file :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
       &lt;Button
          android:id="@+id/buttonSubmit"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true" 
          android:text="Submit"
          android:onClick="onSubmitClick"&gt;
      &lt;/Button&gt;
  
      &lt;GridView
          android:id="@+id/gridView1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_above="@id/buttonSubmit"
          android:layout_alignParentTop="true"
          android:columnWidth="30dp"
          android:gravity="center"
          android:numColumns="auto_fit"
          android:stretchMode="columnWidth" &gt;
      &lt;/GridView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What i want is to iterate through gridview and find textviews with tag1 ... but adapter.getItem returns only string ... any help ?</p>