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
  • 954,112
  • 185
  • 2,315
  • 2,367

1 Answers1

2

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
  • 15,684
  • 6
  • 53
  • 81
Kiril Aleksandrov
  • 2,581
  • 19
  • 27