How to inflate a expandable list in Android? <p>i want to inflate a expandable list with some different text and different images on each row if i use <code>albumCovers.get(i)</code> instead of <code>getResources().getDrawable(R.drawable.icon)</code>then it throws an error, any one help us out? thanks ;p.</p> <pre><code>public class ExpandActivity extends ExpandableListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList&lt;HashMap&lt;String, String&gt;&gt; headerData = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); final HashMap&lt;String, String&gt; group1 = new HashMap&lt;String, String&gt;(); group1.put(NAME, "Group 1"); headerData.add(group1); final ArrayList&lt;ArrayList&lt;HashMap&lt;String, Object&gt;&gt;&gt; childData = new ArrayList&lt;ArrayList&lt;HashMap&lt;String, Object&gt;&gt;&gt;(); final ArrayList&lt;HashMap&lt;String, Object&gt;&gt; group1data = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;(); childData.add(group1data); Resources res = this.getResources(); Drawable photo = (Drawable) res.getDrawable(R.drawable.icon); ArrayList&lt;Drawable&gt; albumCovers = new ArrayList&lt;Drawable&gt;(); albumCovers.add(photo); // Set up some sample data in both groups for (int i = 0; i &lt; 10; ++i) { final HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;(); map.put(NAME, "Child " + i); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); (group1data).add(map); } setListAdapter(new SimpleExpandableListAdapter(this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate // with the field data childData, 0, null, new int[] {}) { @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent); // Populate your custom view here ((TextView) v.findViewById(R.id.name)) .setText((String) ((Map&lt;String, Object&gt;) getChild( groupPosition, childPosition)).get(NAME)); ((ImageView) v.findViewById(R.id.image)) .setImageDrawable((Drawable) ((Map&lt;String, Object&gt;) getChild( groupPosition, childPosition)).get(IMAGE)); return v; } @Override public View newChildView(boolean isLastChild, ViewGroup parent) { return layoutInflater.inflate( R.layout.expandable_list_item_with_image, null, false); } }); } } </code></pre>