title: ArrayAdapter use Kotlin android
body: <p>SoI'm learning kotlin and now I need to write  an ArrayAdapter, but I've some error when trying to do this: </p>
  
  <pre><code>convertView = vi.inflate(resource, null) 
  </code></pre>
  
  <p>kotlin is telling me </p>
  
  <blockquote>
    <p>Val cannot be reassigned</p>
  </blockquote>
  
  <p>In the site kotline I convert java class to kotlin class and try to do like in this site. Why is there an error and how can I fix this? Here is the whole code.</p>
  
  <pre><code>open class MyAdapter(context: Context, resource: Int, list: ArrayList&lt;MyItems&gt;) :
          ArrayAdapter&lt;MyItems&gt;(context, resource, list) {
  
      var resource: Int
      var list: ArrayList&lt;MyItems&gt;
      var vi: LayoutInflater
  
      init {
          this.resource = resource
          this.list = list
          this.vi = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
      }
  
  
      override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
          var holder: ViewHolder
  
          if(convertView == null){
              convertView = vi.inflate(resource, null) //error in this line
              holder = ViewHolder()
  
              holder.image = convertView.findViewById(R.id.myImage) as ImageView?
  
              convertView.tag(holder) //error in this line
  
          } else {
              holder = convertView.tag as ViewHolder
          }
  
          return convertView
      }
  
      internal class ViewHolder {
          var image: ImageView? = null
      }
  
  }
  </code></pre>