filtering a list adapter based from a dialog
<p>I am trying to filter two types of eatery: restaurants and cafes in a list adapter.</p>

<p>Here is the loop which adds the selected type of eatery to the list which will be refreshed in the list adapter:</p>

<pre><code>for (int i = 0; i &lt; filteredTemp.size(); i++) {
    if (filteredTemp.get(i).getType() == _typeOptions[typeSelection].toString()) {
          filtered.add(filteredTemp.get(i));
    }
}
</code></pre>

<p>For a test I have 5 eateries and so <code>filteredTemp</code> will be of size 5 and <code>filtered</code> will begin as an empty <code>ArrayList</code> of type <code>Eatery</code> (the class which stores information such as type, name etc.)</p>

<p>I will also test using <code>typeSelection = 0</code> which is restaurant. <code>filteredTemp</code> contains 2 restaurants and 3 cafes.</p>

<p>Therefore this loop <em>should</em> execute 5 times and execute the code within the if statement twice. However it finds the first restaurant and adds it to the filtered ArrayList and when it finds the second the if statement fails for no apparant reason leaving filtered with only one restaurant instead of two.</p>

<p>Anyone have a clue whats going on? I have used logging statements and it shows the loop executing the correct number of times along with adding the first restaurant but not the second.</p>

<p>Thanks</p>
