title: How can I create icons for menu items in Android's ListView?
body: <p>I am using a <code>ListView</code> to display the main screen of my application.<br>
  The main screen is essentially a <code>menu</code> to get into the different sections of application.  Currently, I have the <code>ListView</code> whose contents are added programmatically in the <code>onCreate</code> method.  </p>
  
  <p>Here is the code snippet that does this:</p>
  
  <pre><code>String[] mainItems = {
      "Inbox", "Projects", "Contexts", "Next Actions"
  }
  
  @Override
  public void onCreate(Bundle icicle) {
      super.onCreate(icicle);
      setContentView(R.layout.main);
  
      setListAdapter(new ArrayAdapter&lt;String&gt;(
              this, android.R.layout.simple_list_item_1, mainItems));
      registerForContextMenu(getListView());
  }
  </code></pre>
  
  <p>So the menu is essentially just a bunch of nodes with the text contained in the mainItems array.  I know that I can create an XML layout (i.e. <code>R.layout.mainMenu_item</code>) that has an ImageView and TextView in it, but I am unsure how to set the ImageView's icon.  I have seen that there is a setImageResouce(int resId) method, but the way to use this when generating with an ArrayAdapter is eluding me.  Is there a better way to do this?</p>