title: Android - Creating Multiple onClickListeners in a for loop (Kotlin)
body: <p>I'm trying to instantiate a large number (~600) onclick listeners for a large grid of buttons. I've created a function that stores the id's of each square in a list called squareList, in which each square is assigned a string value id (sq000, sq001, sq002)</p>
  
  <p>I'd like to create a for loop that pulls the id of each square and then creates an onClicklistener, sort of like:</p>
  
  <pre><code>fun createSquareListeners(listOfSquares: MutableList&lt;String&gt;)
  {
      for(square in listOfSquares)
      {
         square.setOnClickListener{ //Do Something}
      }
  }
  </code></pre>
  
  <p>The other way I thought of implementing this was to write a single onClick function, and attach it to each button in the xml file, but I'm not really sure what's possible as I'm quite new to Kotlin/Java </p>