以下のように、Webサービスから解析された応答を取得しています
<Table>
<Restaurant_ID>2153</Restaurant_ID>
<restaurant_name>Bhagini Palace</restaurant_name>
<address>210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore</address>
<costoftwo>Approx Rs. 400 for two (without alcohol)</costoftwo>
<rating>2.6</rating>
<timings>11:30 AM to 4 PM, 6:30 PM to 11 PM</timings>
<Phone>08040799999,+919731323333</Phone>
<Location_ID>53</Location_ID>
<Location_name>Domlur</Location_name>
<city_ID>1</city_ID>
<city_name>Bangalore</city_name>
<Cuisine_ID>8</Cuisine_ID>
<Cuisine_name>North Indian</Cuisine_name>
</Table>
<Table>
<Restaurant_ID>2153</Restaurant_ID>
<restaurant_name>Bhagini Palace</restaurant_name>
<address>210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore</address>
<costoftwo>Approx Rs. 400 for two (without alcohol)</costoftwo>
<rating>2.6</rating>
<timings>11:30 AM to 4 PM, 6:30 PM to 11 PM</timings>
<Phone>08040799999,+919731323333</Phone>
<Location_ID>53</Location_ID>
<Location_name>Domlur</Location_name>
<city_ID>1</city_ID>
<city_name>Bangalore</city_name>
<Cuisine_ID>13</Cuisine_ID>
<Cuisine_name>Chinese</Cuisine_name>
</Table>
<Table>
<Restaurant_ID>2153</Restaurant_ID>
<restaurant_name>Bhagini Palace</restaurant_name>
<address>210, 1st Main, 'A' Cross, ESI Hospital Road, 2nd Stage, Domlur, Bangalore</address>
<costoftwo>Approx Rs. 400 for two (without alcohol)</costoftwo>
<rating>2.6</rating>
<timings>11:30 AM to 4 PM, 6:30 PM to 11 PM</timings>
<Phone>08040799999,+919731323333</Phone>
<Location_ID>53</Location_ID>
<Location_name>Domlur</Location_name>
<city_ID>1</city_ID>
<city_name>Bangalore</city_name>
<Cuisine_ID>26</Cuisine_ID>
<Cuisine_name>Andhra</Cuisine_name>
</Table>
customadapter を使用して、リストビューに restaurant_name と Cuisines を表示しています
holder.txtvalue.setText(mlist.get(position)
.getRestaurant_name()
+ "\n"
+ mlist.get(position).getCuisine_name());
しかし、レストランIDが同じ場合、料理名をグループ化し、リストビューに表示する必要があります。
私はこのようなことを試しました
cuisines = mlist.get(position).getCuisine_name();
Integer id = mlist.get(position).getRestaurant_ID();
Log.d("restaurant_id", ""+id);
for (int i = 1; i < 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);
しかし、私は個人だけでなくグループでも料理名を取得します。
個々のものを表示しないようにするにはどうすればよいですか?
ありがとう:)