0

I have View. How to get and edit children inside View.

View myTable = inflater.inflate(R.layout.letters_table, container);

// Get and edit myTable children
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491

1 Answers1

3

Not all Views have children. Only ViewGroup instances have. If you want to get the children of an inflated View try this:

if (view instanceof ViewGroup) {
  ViewGroup viewGroup = (ViewGroup) view;
  for(int i = 0; i< viewGroup.getChildCount(); ++i) {
    View child = viewGroup.getChildAt(i);
    // Edit the child
  }
}
Adam S
  • 16,144
  • 6
  • 54
  • 81
Kiril Aleksandrov
  • 2,601
  • 20
  • 27