title: create a custom spinner adapter in android using kotlin
body: <p>I'm trying make a spinner with a custom adapter to display images with text like the following</p>
  <p><img src="https://i.stack.imgur.com/hiBd9.png" alt="the result I want" /></p>
  <p>but I got lots of unresolved references so I think I'm doing something terribly wrong</p>
  <p>I have two fragments the spinner is inside the second fragment
  custome_spinner.xml is the custom layout file</p>
  <p>android studio 3.1.2</p>
  <p>kotlin_version = '1.2.30'</p>
  <p>gradle:3.1.2</p>
  <pre><code> customeSpinnerAdapter.kt
  import android.content.Context
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  import android.widget.BaseAdapter
  
  class customeSpinnerAdapter : BaseAdapter{
      override fun getItem(p0: Int): Any {
          return flag.length
      }
  
      override fun getItemId(p0: Int): Long {
          return null
      }
  
      override fun getCount(): Int {
          return 0
      }
  
      val country:String
      val flag:String
       fun customeSpinnerAdapter(context:Context,name:String,image:String){
          this.country = name
          this.flag = image
  
          val inflater  = LayoutInflater.from(context)
      }
      override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
          val view = inflater.inflate(R.layout.custome_spinner)
          spinner_image.setImageResource(flag)
          spinner_country.setText(country)
          return view
      }
  }
  </code></pre>
  <pre><code>custome_spinner.xml
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;horizontal&quot;&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/spinner_image&quot;
          android:layout_width=&quot;50dp&quot;
          android:layout_height=&quot;50dp&quot;
          android:padding=&quot;5dp&quot;
          android:src=&quot;@drawable/us&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/spinner_country&quot;
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:paddingLeft=&quot;10dp&quot;
          android:paddingRight=&quot;10dp&quot;
          android:layout_gravity=&quot;center&quot;
          android:text=&quot;Custom Text&quot;
          android:textColor=&quot;#000&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <pre><code> the widget inside fragment_second.xml 
  
          &lt;Spinner
              android:id=&quot;@+id/spinner&quot;
              android:layout_width=&quot;368dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginEnd=&quot;8dp&quot;
              android:layout_marginLeft=&quot;8dp&quot;
              android:layout_marginRight=&quot;8dp&quot;
              android:layout_marginStart=&quot;8dp&quot;
              android:layout_marginTop=&quot;12dp&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintHorizontal_bias=&quot;0.0&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/from_textView&quot; /&gt;
  
  </code></pre>