Building a menu with a ListView
<p>My app has a main menu, and I am using a ListView to represent it. Since it's a menu, I will be implementing actions based on which item a user clicks on.</p>

<p>My current implementation looks like this:</p>

<ul>
<li>In strings.xml, I have a string array of the names of the menu items.</li>
<li>In the main menu's activity, I inflate the string array: <code>itemList = getResources().getStringArray(R.array.main_menu_array);</code> (itemList is a static <code>String[]</code>)</li>
<li>Then I set an adapter for the ListView: <code>listView.setAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.main_menu_item, itemList));</code> (<code>R.layout.main_menu_item</code> specifies the layout for each individual menu item. It basically is just a TextView with a couple of attributes.)</li>
<li>I set up an <code>OnItemClickListener</code> for the ListView. </li>
</ul>

<p>The anonymous OnItemClickListener class implements onItemClick() like this</p>

<pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
        long id) {
    switch (position) {
    case POS_ITEM_A:
        ... break;
    case POS_ITEM_B:
        ... break;
    }
}
</code></pre>

<p><code>POS_ITEM_A</code> and <code>POS_ITEM_B</code> are <code>final static</code> variables set to 0 and 1 respectively.</p>

<p>I don't think this is good code. How can I fix it?</p>
