title: Dynamically set images in custom listview
body: <p>can someone explain me what i am doing wrong/what i have to do?</p>
  
  <p>I have a listview that is getting its information from a json array. But it is a custom listview, with 5 images and some text on each row. Each image has a /drawable/image_selector with different images according to enabled/disabled. I am able to dynamically set the text for each row, using hashmap and a ListAdapter. But i am trying to do the same with the images and i am not able to do it. is using a custom adapter the right choice? and if so how? i have not understood from the examples how to use them.</p>
  
  <p>Thanks</p>
  
  <p>here is the code for the given activity:
      public class DisponiveisActivity extends ListActivity {
  ;
      //para os icones do layout</p>
  
  <pre><code>private ProgressDialog pDialog;
  
  //Object of class JSON Parser
  JSONParser jsonParser = new JSONParser();
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; disponiveislist;
  
  
  public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.list);
  
  
      disponiveislist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      new Loaddisp().execute();
  
  }
  //Background ASYNC task to load
  
  class Loaddisp extends AsyncTask&lt;String, String, String&gt;{
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(DisponiveisActivity.this);
          pDialog.setMessage("Carregando");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(false);
          pDialog.show();
      }
  
  
  
      protected String doInBackground(String... args) {
  
  
                  String nome = l.getString("NOME");
                  String preco = l.getString("PRECO");
                  String cfotografia = l.getString("COMFOTOGRAFIA");
                  String cdados = l.getString("COMDADOS");
                  String copiniao = l.getString("COMOPINIAO");
  
                  String cdeslocacao = l.getString("COMDESLOCACAO");
  
  
  
                  String distancia = l.getString("DISTANCIA");
  
                  //create new HASHMAP                    
                  HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
                  map.put("NOME", nome);  
                  map.put("PRECO", preco);
                  map.put("DISTANCIA", distancia);
                  map.put("COMOPINIAO", copiniao);
                  map.put("COMDADOS", cdados);
                  map.put("COMFOTOGRAFIA", cfotografia);
                  //------------------------------
  
  
                  disponiveislist.add(map);
  
              }
  
  
  
  
      @Override
      protected void onPostExecute(String file_url) {
          // TODO Auto-generated method stub
  
          pDialog.dismiss();
          runOnUiThread(new Runnable() {
              public void run() {
                  /**
                   * Updating parsed JSON data into ListView
                   * */
  
  
  
                      Log.d("PP",disponiveislist.toString());
                  ListAdapter adapter = new SimpleAdapter(DisponiveisActivity.this, disponiveislist, R.layout.listrow,new String[]{"NOME","PRECO","DISTANCIA"}, new int[]{R.id.mission_name, R.id.preco, R.id.cdistancia});
  
  
  
  
                  setListAdapter(adapter);
  
  
              }
          });
      }
  
  
  
      }
  </code></pre>
  
  <p>}</p>