title: How can I populate ArrayAdapter with objects?
body: <p>I have a POJO like this:</p>
  
  <pre><code>public class Color {
   private int id;
   private int name;
   //getter setter
  }
  </code></pre>
  
  <p>In my AsyncTask I call the server and get bunch of these objects and then want to populate my list. I do this by:</p>
  
  <pre><code>    @Override
      protected String doInBackground(String... strings) {
          colorsList = MyManager.INSTANCE.getService().getColors();
          return null;
      }
  
      @Override
      protected void onPostExecute(String file_url) {
          setListAdapter(new ArrayAdapter&lt;Color&gt;(MyActivity.this,R.layout.list_black_text,R.id.name, colorsList));
      }
  </code></pre>
  
  <p><code>list_black_text</code> looks like below:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  
      &lt;!-- hidden color id--&gt;
      &lt;TextView
      android:id="@+id/color_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:visibility="gone" /&gt;
  
      &lt;!--color name--&gt;
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textSize="16dip"
          android:textColor="#000000"
          android:paddingTop="15dip"
          android:paddingBottom="15dip"
          android:paddingLeft="10dip"
          android:textStyle="bold"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>When I run the app the list seems to be populated by objects so I see it being populated with stuff like</p>
  
  <pre><code>com.my.package.Color@2343fa0
  com.my.package.Color@2343fa0
  ...
  </code></pre>
  
  <p>What do I need to change so that I can see the name of the color in the list? </p>
  
  <p>Note: I don't want to create a separate string array. I have tried that and it works. But I have additional requirement of being able to detect which <code>ID</code> color was clicked when the user clicks on a color name. </p>