Iterate Through All Objects In Gridview
i am working on CrossWord application for Android. I have a gridview public class MainActivity extends Activity { private GridView gridView; private Button button; private ArrayA
Solution 1:
You can iterate over all children of a GridView (or any other ViewGroup) with getChildAt():
for(inti=0; i < myGridView.getChildCount(); i++) {
TextViewchild= (TextView) mGridView.getChildAt(i);
// do stuff with child view
}
Notice that sometimes a GridView's child is another ViewGroup, so you may need to loop through it's children, etc.
However... a better way to do this might be to keep a separate List of "tagged" elements. You can simply add them to the list when tagged and iterate over the entire list.
Post a Comment for "Iterate Through All Objects In Gridview"