0

我从 webservice 得到解析的响应,如下所示

<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 在列表视图中显示餐厅名称和美食

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);

但我会在团体和个人中获得美食名称。

我怎样才能避免显示个人的?

谢谢:)

4

1 回答 1

0

使用可展开的列表视图。根据餐厅 ID 填充组视图,子视图可以是餐厅中的每个项目。看看那里可用的教程来做到这一点。

可展开的列表视图

于 2013-03-27T10:17:08.870 回答