how to access to a specific element of every grid view item

十年热恋 提交于 2019-12-05 01:22:38

This is simple:

GridView mGridView (Your object instance)

final int size = mGridView.getChildCount();
for(int i = 0; i < size; i++) {
  ViewGroup gridChild = (ViewGroup) mGridView.getChildAt(i);
  int childSize = gridChild.getChildCount();
  for(int k = 0; k < childSize; k++) {
    if( gridChild.getChildAt(k) instanceof TextView ) {
      gridChild.getChildAt(k).setVisibility(View.GONE);
    }
  }
}

The right way to get the view of the listView for a specific position is the next one:

View viewItem = list.getChildAt(position);
if (viewItem != null) {                 
   TextView text = (TextView) viewItem.findViewById(R.id.item);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!