title: Right way to iterate over GridLayout children with setOnClickListener in order to animate with stateListAnimator
body: <p>I have a GridLayout (central_container) with 4 clickable images and animation defined in xml (animator/press_button_animation) that describes object behavior on click (press/release).
  I try to connect this animation to the images in the code.
  It works fine for one of four images if it is hardcoded:</p>
  <pre><code>private fun initAnimation() {
      val stateListAnimator = loadStateListAnimator(
          this,
          R.animator.press_button_animation
      )
      central_container.getChildAt(0).setOnClickListener {
          it.stateListAnimator = stateListAnimator
      }
  }
  </code></pre>
  <p>What is the right way to make it work on all GridLayout children?</p>
  <p>I've tried with for loop but it stops on last image. For example if I click one by one and reach the last one, the previous images stop to react</p>
  <pre><code>private fun initAnimation() {
      val stateListAnimator = loadStateListAnimator(
          this,
          R.animator.press_button_animation
      )
      for (n in 0 until central_container.size) {
          val img = central_container.getChildAt(n)
          img.setOnClickListener {
              it.stateListAnimator = stateListAnimator
          }
      }
  }
  </code></pre>
  <p>I'm sorry for being not clear enough. After number of trials and experiments I'll try to explain more exactly.
  I have 4 clickable images and expect each one to be animated on click.
  The problem is that inspite of each image responds to click rigth (I checked it in debugger) but the problem is with animation. For example, first image animates well, then second image animates well. But if after the second I click on first, it is clicking but the second image is the one who animates. And so on...
  Or, for example if I click images one by one by order (1-2-3-4) each one animates well. Then, if I click on 1 or 2 or 3 so the one who animates is still 4.
  Seems like there is a need to &quot;reset&quot; animation after each click somehow or anything like that.</p>