Android dynamic icon in listview
<p>I have a ListActivity in my application.  The list is populated from a parsed http response in the form of an ArrayList of hashmaps.</p>

<pre>final ArrayList&lt;HashMap&lt;String,String>> LIST = new ArrayList&lt;HashMap&lt;String,String>>();
...
SimpleAdapter adapter = new SimpleAdapter(this, LIST, R.layout.item_row, new String[]{"author","title"}, new int[]{R.id.text1,R.id.text2});
setListAdapter(adapter);
...
for(Element src : lists){
     String title = src.select();
     String author = src.select();
     HashMap&lt;String,String> temp = new HashMap&lt;String,String>();
     temp.put("author", author);
     temp.put("title", title);
     LIST.add(temp);
}
</pre>

<p>Where author and title are correctly derived from the parsed http.</p>

<p>In the R.layout.item_row XML file I have defined a drawable for text2:</p>

<pre>android:drawableLeft="@drawable/default_icon"</pre>

<p>And i would like to be able to change that icon to "new_icon" on a given row if the hashmap contains a certain string.</p>

<p>For instance, within the for loop above, I would add something like:</p>

<pre>
String status = src.select();
String icon = "default";
if(status.contains("test")){
     icon = "should_change";
}
temp.put("icon", icon);
...etc
</pre>

<p>I'm leaving out the specific logic for brevity, but I am able to correctly pass whether the icon should change or not as a string value back to the adapter, however, I am not sure how to then actually change the icon.</p>

<p>I am not experienced with either Java or Android so I am quite likely approaching this backwards.</p>

<p>Any help would be great.</p>
