title: Change attributes of an external object in Adapter of non specified number of objects in Adapter
body: <p>i'm quite new in Kotlin and i would like to start programming as much efficient as possible, that means in this example having a non specified number of objects in my adapter. I'm trying to make a list of buttons 2 to non specified and then do onClick events which should change a 1 text ot of the list of buttons, but i'm struggling with making it visible and editable in "MyCustomAdapter: BaseAdapter()".
  Maybe specify it inside of an Adapter ? I'm not really sure, somehelp would be nice, thanks.</p>
  
  <pre><code>class ChoosingSpells : AppCompatActivity() {
  
  private fun spellSpec(spellCode: Int, index: Int): String {                                        // going to be server function...or partly made from server
      val returnSpec = when(spellCode) {
          3 -&gt; arrayOf("Fire Ball","@drawable/firespell", "20","level","description")
          4 -&gt; arrayOf("Freezing touch", "@drawable/icespell","30","level","description")
          5 -&gt; arrayOf("Wind hug", "@drawable/windspell","40","level","description")
          else -&gt; arrayOf("null","null","null")
      }
      return returnSpec[index]
  }
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_choosing_spells)
  
      val listView = findViewById&lt;ListView&gt;(R.id.choosing_listview)
  
      textLabel.text  = "This works in here"
      listView.adapter = MyCustomAdapter()
  }
  
      private class MyCustomAdapter: BaseAdapter() {
  
  
          private val learnedSpells = arrayOf(3,4,5,0,0,3,4,5,0,0,3,4,5,0,0,3,4,5,0,0,3,4,5,0,0,3,4,5,0,0,3,4,5,0,0,3,4,5,0,0)
          private val spellsInUse = arrayOf(0,0,0,0,0)
  
  
          override fun getCount(): Int {
              return (learnedSpells.size/2)
          }
  
          override fun getItemId(position: Int): Long {
              return position.toLong()
          }
  
          override fun getItem(position: Int): Any {
              return "TEST STRING"
          }
  
          override fun getView(position: Int, convertView: View?, viewGroup: ViewGroup?): View {
              val rowMain: View
  
              if (convertView == null) {
                  val layoutInflater = LayoutInflater.from(viewGroup!!.context)
                  rowMain = layoutInflater.inflate(R.layout.row_choosingspells, viewGroup, false)
                  val viewHolder = ViewHolder(rowMain.button1, rowMain.button2)
                  rowMain.tag = viewHolder
              } else {
                  rowMain = convertView
              }
              val viewHolder = rowMain.tag as ViewHolder
  
              viewHolder.button1.setBackgroundResource(getDrawable(learnedSpells[if(position==0){0}else{position*2}]))
              viewHolder.button2.setBackgroundResource(getDrawable(learnedSpells[if(position==0){1}else{position*2+1}]))
              var clicks1 = 0
              var clicks2 = 0
              viewHolder.button1.setOnClickListener {
                  clicks1++
                  if(clicks1==1){         //single click
                      /*textLabel.text = spellSpec(learnedSpells[if(position==0){0}else{position*2}],0)  I just want to change text of an external label, which is not part of the adapter here
                      textLevel.text = spellSpec(learnedSpells[if(position==0){0}else{position*2}],3)
                      textStats.text = spellSpec(learnedSpells[if(position==0){0}else{position*2}],2)
                      textDescription.text = spellSpec(learnedSpells[if(position==0){0}else{position*2}],4)*/
                      textLabel.text  = "This doesn't work here"
                  }else if(clicks1==2){
  
                  }
                  clicks1=0
              }
              viewHolder.button2.setOnClickListener {
                  clicks2++
                  if(clicks2==1){         //single click
                      /*textLabel.text = spellSpec(learnedSpells[if(position==0){1}else{position*2+1}],0)
                      textLevel.text = spellSpec(learnedSpells[if(position==0){1}else{position*2+1}],3)
                      textStats.text = spellSpec(learnedSpells[if(position==0){1}else{position*2+1}],2)
                      textDescription.text = spellSpec(learnedSpells[if(position==0){1}else{position*2+1}],4)*/
                  }else if(clicks2==2){   //double click
  
                  }
                  clicks2=0
              }
              return rowMain
          }
          private fun getDrawable(index:Int): Int {
              return(when(index) {
                  3 -&gt; R.drawable.firespell
                  4 -&gt; R.drawable.icespell
                  5 -&gt; R.drawable.windspell
                  0 -&gt; R.drawable.shield
                  else -&gt; NULL
              }
              )
          }
  
          private class ViewHolder(val button1: TextView, val button2: TextView)
  
      }
  </code></pre>
  
  <p>}</p>