grouping the similar items
<p>I am getting the parsed response from webservice as below </p>

<pre><code>&lt;Table&gt;
    &lt;Restaurant_ID&gt;2153&lt;/Restaurant_ID&gt;
    &lt;restaurant_name&gt;Bhagini Palace&lt;/restaurant_name&gt;
    &lt;address&gt;210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore&lt;/address&gt;
    &lt;costoftwo&gt;Approx Rs. 400 for two (without alcohol)&lt;/costoftwo&gt;
    &lt;rating&gt;2.6&lt;/rating&gt;
    &lt;timings&gt;11:30 AM to 4 PM, 6:30 PM to 11 PM&lt;/timings&gt;
    &lt;Phone&gt;08040799999,+919731323333&lt;/Phone&gt;
    &lt;Location_ID&gt;53&lt;/Location_ID&gt;
    &lt;Location_name&gt;Domlur&lt;/Location_name&gt;
    &lt;city_ID&gt;1&lt;/city_ID&gt;
    &lt;city_name&gt;Bangalore&lt;/city_name&gt;
    &lt;Cuisine_ID&gt;8&lt;/Cuisine_ID&gt;
    &lt;Cuisine_name&gt;North Indian&lt;/Cuisine_name&gt;
  &lt;/Table&gt;
  &lt;Table&gt;
    &lt;Restaurant_ID&gt;2153&lt;/Restaurant_ID&gt;
    &lt;restaurant_name&gt;Bhagini Palace&lt;/restaurant_name&gt;
    &lt;address&gt;210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore&lt;/address&gt;
    &lt;costoftwo&gt;Approx Rs. 400 for two (without alcohol)&lt;/costoftwo&gt;
    &lt;rating&gt;2.6&lt;/rating&gt;
    &lt;timings&gt;11:30 AM to 4 PM, 6:30 PM to 11 PM&lt;/timings&gt;
    &lt;Phone&gt;08040799999,+919731323333&lt;/Phone&gt;
    &lt;Location_ID&gt;53&lt;/Location_ID&gt;
    &lt;Location_name&gt;Domlur&lt;/Location_name&gt;
    &lt;city_ID&gt;1&lt;/city_ID&gt;
    &lt;city_name&gt;Bangalore&lt;/city_name&gt;
    &lt;Cuisine_ID&gt;13&lt;/Cuisine_ID&gt;
    &lt;Cuisine_name&gt;Chinese&lt;/Cuisine_name&gt;
  &lt;/Table&gt;
  &lt;Table&gt;
    &lt;Restaurant_ID&gt;2153&lt;/Restaurant_ID&gt;
    &lt;restaurant_name&gt;Bhagini Palace&lt;/restaurant_name&gt;
    &lt;address&gt;210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore&lt;/address&gt;
    &lt;costoftwo&gt;Approx Rs. 400 for two (without alcohol)&lt;/costoftwo&gt;
    &lt;rating&gt;2.6&lt;/rating&gt;
    &lt;timings&gt;11:30 AM to 4 PM, 6:30 PM to 11 PM&lt;/timings&gt;
    &lt;Phone&gt;08040799999,+919731323333&lt;/Phone&gt;
    &lt;Location_ID&gt;53&lt;/Location_ID&gt;
    &lt;Location_name&gt;Domlur&lt;/Location_name&gt;
    &lt;city_ID&gt;1&lt;/city_ID&gt;
    &lt;city_name&gt;Bangalore&lt;/city_name&gt;
    &lt;Cuisine_ID&gt;26&lt;/Cuisine_ID&gt;
    &lt;Cuisine_name&gt;Andhra&lt;/Cuisine_name&gt;
  &lt;/Table&gt;
</code></pre>

<p>I am displaying restaurant_name and Cuisines in the listview using customadapter as</p>

<pre><code>holder.txtvalue.setText(mlist.get(position)
                        .getRestaurant_name()
                        + "\n"
                        + mlist.get(position).getCuisine_name());
</code></pre>

<p>but when the restaurant id's are same i want to group the cuisines name and need to display in listview.</p>

<p>i have tried something like this</p>

<pre><code>cuisines = mlist.get(position).getCuisine_name();

                Integer id = mlist.get(position).getRestaurant_ID();
                Log.d("restaurant_id", ""+id);
                for (int i = 1; i &lt; 10; i++) {

                    if (id.equals(mlist.get(position+i).getRestaurant_ID())) {

                        if(id.equals(mlist.get(position+(i+1)).getRestaurant_ID())){

                            cuisines = cuisines +","+ mlist.get(position+i).getCuisine_name()
                                    +","+ mlist.get(position+(i+1)).getCuisine_name();  
                        }else

                        cuisines = cuisines +","+ mlist.get(position+i).getCuisine_name();
                        Log.d("cuisiene_id", ""+cuisines);
                    }
                }
                holder.txtvalue.setText(mlist.get(position)
                        .getRestaurant_name() + "\n" + cuisines);
</code></pre>

<p>But i will get cuisines name in group as well as individuals. </p>

<p>How can i avoid displaying individual one's?</p>

<p>Thanks:)</p>
