title: How do I use Glide with GridView? (Android/Kotlin)
body: <p>I have successfully constructed a <code>gridView</code> using this code:</p>
  
  <pre><code>override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
  
      var inflater = mContext!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
      var row = inflater.inflate(R.layout.image_cell, null)  
  
      row!!.glide_img_cell_id.setImageResource(R.drawable.cookie_icon_60)
  
      return row
  }
  </code></pre>
  
  <p>It returns the test image as it should in the <code>gridView</code>
  However, my real image data comes from <code>urls</code> so I'm using <code>Glide</code>. I have already done a check with my real data using <code>Glide</code> and it works fine. However, I can't seem to get it to work in my <code>GridView</code>. This is my altered code: </p>
  
  <pre><code>override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
  
      var recipe = this.recipeArray!![position].recipeImage
      var inflater = mContext!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
      var row = inflater.inflate(R.layout.image_cell, null)  
  
      row!!.glide_img_cell_id.loadImageUrl(recipe) as GlideImageView
  
      return row
  }
  </code></pre>
  
  <p>I'm doing the same thing except that I now use <code>Glide</code>. Also, another thing I'm confused about is <code>convertView</code>. Some tutorials I've watched use it, others don't. What is it? Obviously I didn't need it in my first example as it worked.</p>
  
  <p><strong><em>UPDATE</em></strong>
  Casting to <code>GlideImageView</code> the app crashes with <code>kotlin.Unit cannot be cast to com.bumptech.glide.Glide</code>, without casting it simply does not show anything.</p>
  
  <p><strong><em>UPDATE2</em></strong> 
  As suggested, I changed the code to the following, but the app is still blank and shows nothing:</p>
  
  <pre><code>override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
      var recipe = this.recipeArray!![position].recipeImage
  
      var inflater = mContext!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
      var row = inflater.inflate(R.layout.image_cell, null)  
      Glide.with(mContext).load(recipe).fitCenter().centerCrop().into(row!!.glide_img_cell_id)
  
      return row
  }
  </code></pre>
  
  <p>Does this seem right?</p>
  
  <p><strong><em>UPDATE</em></strong>
  Still haven't solved this. Have looked into the xml file that should contain the image. Looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/glide_img_cell_id"
      android:layout_centerInParent="true"
      android:scaleType="centerCrop"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Have also used <code>&lt;com.master.glideimageview.GlideImageView</code> instead of <code>&lt;ImageView</code> but still nothing.</p>
  
  <p>Have also tried this: </p>
  
  <pre><code>override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
      var recipe = this.recipeArray!![position].recipeImage
  
      var cv = convertView
      var test = LayoutInflater.from(mContext)
      cv = test.inflate(R.layout.image_cell, parent, false)
  
      Glide.with(this.mContext).load(recipe).into(cv!!.glide_img_cell_id as ImageView)
  
      return cv
  }
  </code></pre>
  
  <p>...which is similar. But that doesn't work either. Don't know why it doesn't work...</p>