title: How to implement For-loop logic in Spinner (android Kotlin)
body: <p>I have 6 repetitive codes and I just want to use for-loop logic.
  I tried to use &quot;getIdentifier&quot; and &quot;findViewById&quot; But I failed.</p>
  <pre><code> val sb_spinner_secret_p1: Spinner = findViewById(R.id.sb_secret1)  
          ArrayAdapter.createFromResource(this, R.array.secret, android.R.layout.simple_spinner_item
          ).also { adapter -&gt;
              adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
              sb_spinner_secret_p1.adapter = adapter
          }
  </code></pre>
  <p>I tried this but it never works</p>
  <pre><code>for(i in 1..7){
              val sb_spinner = &quot;sb_spinner_secret_p$i&quot;
              val sbsecret = &quot;sb_secret$i&quot;
              val sb_spinner_resId = resources.getIdentifier(sb_spinner,&quot;id&quot;, packageName)
              val sbsecret_resId = resources.getIdentifier(sbsecret,&quot;id&quot;, packageName)
          }
  </code></pre>