title: How to create Spinner-list using CustomAdapter in android
body: <p>in my app,I want to create SpinnerList using CustomAdapter class,For this i wrote below code but when I tap on spinner list then array-List images are not loading in spinner-list as like my below screen why this problem is coming? </p>
  
  <h2>main_layout.xml:-</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="10dip"
          android:text="Category:"
          android:layout_marginBottom="5dp"/&gt;
  
      &lt;Spinner
          android:id="@+id/spinner"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <h2>MainActivity:-</h2>
  
  <pre><code>public class MainActivity extends AppCompatActivity  {
  
      public static final String[] titles = new String[] { "Strawberry",
              "Banana", "Orange", "Hello" };
  
      public static final Integer[] images = { R.drawable.image1,
              R.drawable.image2, R.drawable.image3, R.drawable.image4 };
  
      Spinner spinner;
      List&lt;RowItem&gt; rowItems;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_layout);
  
          rowItems = new ArrayList&lt;RowItem&gt;();
          for (int i = 0; i &lt; titles.length; i++) {
  
              RowItem item = new RowItem(titles[i],images[i]);
              rowItems.add(item);
          }
  
          spinner = (Spinner)findViewById(R.id.spinner);
         CustomAdapter adapter = new CustomAdapter(MainActivity.this,
              R.layout.listitems_layout, R.id.title, rowItems);
          spinner.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <h2>listitems_layout.xml:-</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"&gt;
  
      &lt;ImageView
          android:id="@+id/icon"
          android:layout_width="80dp"
          android:layout_height="80dp"
          android:src="@drawable/image1"
          android:padding="10dp"
          /&gt;
  
      &lt;TextView
          android:layout_marginTop="30dp"
          android:id="@+id/title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_toRightOf="@+id/icon"
          android:textColor="#CC0033"
          android:text="Strawberry"
          android:textSize="16dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <h2>CustomAdapter:-</h2>
  
  <pre><code>package com.example.venkat.spinnerexample1;
  
  
  import android.app.Activity;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.view.LayoutInflater;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.List;
  
  public class CustomAdapter extends ArrayAdapter&lt;RowItem&gt; {
  
      LayoutInflater flater;
  
       public CustomAdapter(Activity context,int resouceId, int textviewId, List&lt;RowItem&gt; list){
  
      super(context,resouceId,textviewId, list);
      flater = context.getLayoutInflater();
  }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          RowItem rowItem = getItem(position);
  
          View rowview = flater.inflate(R.layout.listitems_layout,null,true);
  
          TextView txtTitle = (TextView) rowview.findViewById(R.id.title);
          txtTitle.setText(rowItem.getTitle());
  
          ImageView imageView = (ImageView) rowview.findViewById(R.id.icon);
          imageView.setImageResource(rowItem.getImageId());
  
          return rowview;
      }
  }
  </code></pre>
  
  <h2>RowItem:-</h2>
  
  <pre><code>package com.example.venkat.spinnerexample1;
  
  public class RowItem {
  
      private int ImageId;
      private String Title;
  
      public RowItem(String Title,int ImageId){
  
          this.Title = Title;
          this.ImageId = ImageId;
      }
  
      public String getTitle(){
  
          return Title;
      }
  
      public void setTitle(String Title){
  
          this.Title = Title;
      }
  
      public int getImageId(){
  
          return ImageId;
      }
  
      public void setImageId(int ImageId){
  
          this.ImageId = ImageId;
      }
  
      @Override
      public String toString() {
          return Title ;
      }
  }
  </code></pre>
  
  <p>screen:-
  ---<a href="https://i.stack.imgur.com/neC0V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/neC0V.png" alt="enter image description here"></a></p>