Как добавить многоуровневый расширяемый список?(Android) - PullRequest
0 голосов
/ 20 декабря 2018

У меня есть одноуровневый Expandablelistview в Android, и он отлично работает. Как я могу добавить многоуровневый расширяемый просмотр списка, используя LinkedHashMap Пожалуйста, помогите мне решить, используя LinkedHashMap, который содержит данные

 ExpandableListAdapterParent listAdapter;
    ExpandableListView expListView;
 List<String> listDataHeader;
 LinkedHashMap<String, List<String>> listDataChild;
  listDataHeader = new ArrayList<String>();
    listDataChild = new LinkedHashMap<String, List<String>>();
    // Adding Parent data
    listDataHeader.add("l1");
    listDataHeader.add("l2");
    listDataHeader.add("l3");
    listDataHeader.add("l4");
    listDataHeader.add("l5");
    listDataHeader.add("l6");
    // Adding child data
    List<String> l1= new ArrayList<String>();
    l1.add("item1");
    l1.add("item1");
    l1.add("item1");
    l1.add("item1");
    List<String> l2= new ArrayList<String>();
    l2.add("item2");
    l2.add("item2");
    l2.add("item2");
    l2.add("item2");
    listDataChild.put(listDataHeader.get(0), l1); // Header, Child data
    listDataChild.put(listDataHeader.get(1), l2);
    listDataChild.put(listDataHeader.get(2), l3);
    expListView = (ExpandableListView) findViewById(R.id.lvExp);
     listAdapter = new ExpandableListAdapterParent(this, listDataHeader, 
 listDataChild);
    // setting list adapter
    expListView.setAdapter(listAdapter);

ExpandableListView Адаптер родительского класса приведен ниже, я накачал макет одним объектом textview

public class ExpandableListAdapterParent extends BaseExpandableListAdapter {

private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;

public ExpandableListAdapterParent(Context context, List<String> listDataHeader,
                                   HashMap<String, List<String>> listChildData) {
    this._context = context;
    this._listDataHeader = listDataHeader;
    this._listDataChild = listChildData;
}

@Override
public Object getChild(int groupPosition, int childPosititon) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .get(childPosititon);
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public View getChildView(int groupPosition, final int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {

    final String childText = (String) getChild(groupPosition, childPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_item, null);
    }

    TextView txtListChild = (TextView) convertView
            .findViewById(R.id.lblListItem);

    txtListChild.setText(childText);
    return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .size();
}

@Override
public Object getGroup(int groupPosition) {
    return this._listDataHeader.get(groupPosition);
}

@Override
public int getGroupCount() {
    return this._listDataHeader.size();
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    String headerTitle = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_group, null);
    }

    TextView lblListHeader = (TextView) convertView
            .findViewById(R.id.lblListHeader);
    lblListHeader.setTypeface(null, Typeface.BOLD);
    lblListHeader.setText(headerTitle);

    return convertView;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}

}

1 Ответ

0 голосов
/ 20 декабря 2018

попробуйте, это прекрасно для меня работает

public class ExpandableAdapter extends BaseExpandableListAdapter {

    private LayoutInflater layoutInflater;
    private LinkedHashMap<Item, ArrayList<Item>> groupList;
    private ArrayList<Item> mainGroup;
    private int[] groupStatus;
    private ExpandableListView listView;

    public ExpandableAdapter(Context context, ExpandableListView listView,
            LinkedHashMap<Item, ArrayList<Item>> groupsList) {
        layoutInflater = (LayoutInflater) context
                .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        this.groupList = groupsList;
        groupStatus = new int[groupsList.size()];

        listView.setOnGroupExpandListener(new OnGroupExpandListener() {

            public void onGroupExpand(int groupPosition) {
                Item group = mainGroup.get(groupPosition);
                if (groupList.get(group).size() > 0)
                    groupStatus[groupPosition] = 1;

            }
        });

        listView.setOnGroupCollapseListener(new OnGroupCollapseListener() {

            public void onGroupCollapse(int groupPosition) {
                Item group = mainGroup.get(groupPosition);
                if (groupList.get(group).size() > 0)
                    groupStatus[groupPosition] = 0;

            }
        });

        mainGroup = new ArrayList<Item>();
        for (Map.Entry<Item, ArrayList<Item>> mapEntry : groupList.entrySet()) {
            mainGroup.add(mapEntry.getKey());
        }
    }

    public Item getChild(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        Item item = mainGroup.get(groupPosition);
        return groupList.get(item).get(childPosition);

    }

    public long getChildId(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        return 0;
    }

    public View getChildView(final int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        final ChildHolder holder;
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.group_item, null);
            holder = new ChildHolder();
            holder.cb = (CheckBox) convertView.findViewById(R.id.cb);
            holder.title = (TextView) convertView.findViewById(R.id.title);
            convertView.setTag(holder);
        } 
        else {
            holder = (ChildHolder) convertView.getTag();
        }
        final Item child = getChild(groupPosition, childPosition);
        holder.cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView,
                    boolean isChecked) {
                Item parentGroup = getGroup(groupPosition);
                child.isChecked = isChecked;

                //if the CHILD is checked
                //TODO: Here add/remove from list 

                if (isChecked) {
                    ArrayList<Item> childList = getChild(parentGroup);
                    int childIndex = childList.indexOf(child);
                    boolean isAllChildClicked = true;
                    for (int i = 0; i < childList.size(); i++) {
                        if (i != childIndex) {
                            Item siblings = childList.get(i);
                            if (!siblings.isChecked) {
                                isAllChildClicked = false;
                                //if(DataHolder.checkedChilds.containsKey(child.name)==false){
                                DataHolder.checkedChilds.put(child.name,
                                        parentGroup.name);
                                //  }
                                break;
                            }
                        }
                    }

                    //All the children are checked
                    if (isAllChildClicked) {
                        Log.i("All should be checked", "Each child is Clicked!!");
                        parentGroup.isChecked = true;
                        if(!(DataHolder.checkedChilds.containsKey(child.name)==true)){
                            DataHolder.checkedChilds.put(child.name,
                                    parentGroup.name);
                        }
                        checkAll = false;
                    }
                } 
                //not all of the children are checked
                else {
                    if (parentGroup.isChecked) {
                        parentGroup.isChecked = false;
                        checkAll = false;
                        DataHolder.checkedChilds.remove(child.name);
                    } else {
                        checkAll = true;
                        DataHolder.checkedChilds.remove(child.name);
                    }
                    // child.isChecked =false;
                }
                notifyDataSetChanged();
            }
        });
        holder.cb.setChecked(child.isChecked);
        holder.title.setText(child.name);
        Log.i("The childs/children is/are: ", DataHolder.checkedChilds.toString());
        return convertView;
    }

    public int getChildrenCount(int groupPosition) {
        // TODO Auto-generated method stub
        Item item = mainGroup.get(groupPosition);
        return groupList.get(item).size();
    }

    public Item getGroup(int groupPosition) {
        // TODO Auto-generated method stub
        return mainGroup.get(groupPosition);
    }

    public int getGroupCount() {
        // TODO Auto-generated method stub
        return mainGroup.size();
    }

    public long getGroupId(int groupPosition) {
        // TODO Auto-generated method stub
        return 0;
    }
    //works with the GroupView

    public View getGroupView(final int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {

        final GroupHolder holder;

        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.group_list, null);
            holder = new GroupHolder();
            holder.cb = (CheckBox) convertView.findViewById(R.id.cb);
            holder.imageView = (ImageView) convertView
                    .findViewById(R.id.label_indicator);
            holder.title = (TextView) convertView.findViewById(R.id.title);
            convertView.setTag(holder);
        } else {
            holder = (GroupHolder) convertView.getTag();
        }

        holder.imageView
        .setImageResource(groupStatus[groupPosition] == 0 ? R.drawable.group_down
                : R.drawable.group_up);
        final Item groupItem = getGroup(groupPosition);

        holder.title.setText(groupItem.name);

        holder.cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView,
                    boolean isChecked) {
                if (checkAll) {
                    Log.i("All items should be affected!!", "All are being affected");
                    ArrayList<Item> childItem = getChild(groupItem);

                    for (Item children : childItem) {
                        children.isChecked = isChecked;
                        //TODO: Here update the list 
                    }
                }
                groupItem.isChecked = isChecked;
                notifyDataSetChanged();
                new Handler().postDelayed(new Runnable() {

                    public void run() {
                        // TODO Auto-generated method stub
                        if (!checkAll)
                            checkAll = true;
                    }
                }, 50);

            }

        });
        holder.cb.setChecked(groupItem.isChecked);
        return convertView;
    }

    private boolean checkAll = true;

    private ArrayList<Item> getChild(Item group) {
        return groupList.get(group);
    }

    public boolean hasStableIds() {
        // TODO Auto-generated method stub
        return true;
    }

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        return true;
    }

    private class GroupHolder {
        public ImageView imageView;
        public CheckBox cb;
        public TextView title;

    }

    private class ChildHolder {
        public TextView title;
        public CheckBox cb;
    }
}

Держатель данных

public class DataHolder {
    public static HashMap<String, String> checkedChilds = new HashMap<String, String>();
}

строка вашего элемента

public class Item {
    public String name,id,phNo,phDisplayName,phType;
    protected boolean isChecked;

}

MainActivity

public class MainActivity extends Activity {

    private LinkedHashMap<Item,ArrayList<Item>> groupList;
    private ExpandableListView expandableListView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initViews();
    }


    private void initViews(){
        initContactList();
        expandableListView = (ExpandableListView)findViewById(R.id.expandableListView);
        ExpandableAdapter adapter = new ExpandableAdapter(this, expandableListView, groupList);
        expandableListView.setAdapter(adapter);

    }
    private void initContactList(){
        groupList = new LinkedHashMap<Item,ArrayList<Item>>();

        ArrayList<Item> groupsList = fetchGroups();
        Log.i("GroupsListSize",String.valueOf(groupsList.size()));

        for(Item item:groupsList){
            String[] ids = item.id.split(",");
            ArrayList<Item> groupMembers =new ArrayList<Item>();
            for(int i=0;i<ids.length;i++){
                String groupId = ids[i];
                //              Log.i("GroupId",groupId);
                groupMembers.addAll(fetchGroupMembers(groupId));
            }

            item.name = item.name +" ("+groupMembers.size()+")";
            groupList.put(item,groupMembers);
        }

    }



    private ArrayList<Item> fetchGroups(){
        ArrayList<Item> groupList = new ArrayList<Item>();
        //List each group 
        for(int i=0; i<21; i++){
            Item item = new Item();
            String groupName; 
            if(i==0) {
                item.id = groupName = "Active Life";
            }
            else if(i==1) {
                item.id = groupName = "Arts & Entertainment";
            }
            else if(i==2) {
                item.id = groupName = "Automotive";
            }
            else if(i==3) {
                item.id = groupName = "Beauty & Spas";
            }
            else if(i==4) {
                item.id =groupName = "Bicycles";
            }
            else if(i==5) {
                item.id =groupName = "Education";
            } 
            else if(i==6) {
                item.id = groupName = "Event Planning & Services";
            }
            else if(i==7) {
                item.id=groupName = "Food";
            }
            else if(i==8) {
                item.id=groupName = "Health & Medical";
            }
            else if(i==9) {
                item.id=groupName = "Home Services";
            }
            else if(i==10) {
                item.id=groupName = "Hotels & Travel";
            }
            else if(i==11) {
                item.id=groupName = "Local Flavor";
            }
            else if(i==12) {
                item.id= groupName = "Local Services";
            }
            else if(i==13) {
                item.id=groupName = "Mass Media";
            }
            else if(i==14) {
                item.id=groupName = "Night Life";
            }
            else if(i==15) {
                item.id=groupName = "Pets";
            }
            else if(i==16) {
                item.id=groupName = "Professional Services";
            }
            else if(i==17) {
                item.id=groupName = "Public Services & Government";
            }
            else if(i==18) {
                item.id=groupName = "Real Estate";
            }
            else if(i==19) {
                item.id=groupName = "Religious Organizations";
            }
            else if(i==20) {
                item.id=groupName = "Restaurants";
            }
            else {
                item.id=groupName = "Shopping";
            }
            item.name = groupName;
            groupList.add(item);    
        }
        Collections.sort(groupList,new Comparator<Item>() {

            public int compare(Item item1, Item item2) {

                return item2.name.compareTo(item1.name)<0
                        ?0:-1;
            }
        });
        return groupList;
    }

    private ArrayList<Item> fetchGroupMembers(String groupId){
        ArrayList<Item> groupMembers = new ArrayList<Item>(); 

        if(groupId.equals("Active Life")) {
            String[] toAdd = {"active life","amateur sports teams","amusement parks","aquariums","archery","badminton","bathing area","beaches","bicycle paths","bike rentals","boating","bowling","bungee jumping","climbing","disc golf","diving","free diving","scuba diving","experiences","fishing","fitness & instruction","barre classes","boot camps","boxing","dance studios","gyms","martial arts","pilates","swimming lessons/schools","tai chi","trainers","yoga","gliding","go karts","golf","gun/rifle ranges","gymnastics","hang gliding","hiking","horse racing","horseback riding","hot air balloons","indoor playcentre","kids activities","kiteboarding","lakes","laser tag","lawn bowling","leisure centers","mini golf","mountain biking","nudist","paddleboarding","paintball","parks","dog parks","skate parks","playgrounds","public plazas","rafting/kayaking","recreation centers","rock climbing","sailing","skating rinks","skiing","skydiving","soccer","spin classes","sport equipment hire","sports clubs","squash","summer camps","surfing","swimming pools","tennis","trampoline parks","tubing","zoos","zorbing"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Arts & Entertainment")) {
            String[] toAdd = {"arts & entertainment","arcades","art galleries","betting centers","botanical gardens","casinos","castles","choirs","cinema","cultural center","festivals","christmas markets","fun fair","general festivals","trade fairs","jazz & blues","marching bands","museums","music venues","opera & ballet","performing arts","professional sports teams","psychics & astrologers","race tracks","social clubs","stadiums & arenas","street art","tablao flamenco","ticket sales","wineries"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Automotive")) {
            String[] toAdd ={"automotive","auto detailing","auto glass services","auto loan providers","auto parts & supplies","auto repair","boat dealers","body shops","car dealers","car stereo installation","car wash","gas & service stations","motorcycle dealers","motorcycle repair","oil change stations","parking","rv dealers","smog check stations","tires","towing","truck rental","windshield installation & repair"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Beauty & Spas")) {
            String[] toAdd = {"beauty & spas","barbers","cosmetics & beauty supply","day spas","eyelash service","hair extensions","hair removal","laser hair removal","hair salons","blow dry/out services","hair extensions","hair stylists","men's hair salons","makeup artists","massage","medical spas","nail salons","perfume","permanent makeup","piercing","rolfing","skin care","tanning","tattoo"} ;
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Bicycles")) {
            String[] toAdd = {"bicycles","bike associations","bike repair","bike shop","special bikes"};
            groupMembers = addMyMembers(toAdd);
        }

        else if(groupId.equals("Education")) {
            String[] toAdd = {"education","adult education","college counseling","colleges & universities","educational services","elementary schools","middle schools & high schools","preschools","private schools","private tutors","religious schools","special education","specialty schools","art schools","cpr classes","circus schools","cooking schools","cosmetology schools","dance schools","driving schools","first aid classes","flight instruction","language schools","massage schools","swimming lessons/schools","vocational & technical school","test preparation","tutoring centers"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Event Planning & Services ")) {
            String[] toAdd = {"event planning & services","bartenders","boat charters","cards & stationery","caterers","clowns","djs","hotels","magicians","musicians","officiants","party & event planning","party bus rentals","party equipment rentals","party supplies","personal chefs","photographers","event photography","session photography","venues & event spaces","videographers","wedding planning"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Financial Services")) {
            String[] toAdd = {"financial services","banks & credit unions","check cashing/pay-day loans","financial advising","insurance","investing","tax services"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Food")) {
            String[] toAdd = {"food","bagels","bakeries","beer, wine & spirits","beverage store","breweries","bubble tea","butcher","csa","churros","coffee & tea","convenience stores","delicatessen","desserts","do-it-yourself food","donairs","donuts","ethic grocery","farmers market","food delivery services","food trucks","friterie","gelato","grocery","ice cream & frozen yogurt","internet cafes","juice bars & smoothies","kiosk","mulled wine","organic stores","parent cafes","patisserie/cake shop","pretzels","shaved ice","specialty food","candy stores","cheese shops","chocolatiers & shops","ethnic food","fruits & veggies","health markets","herbs & spices","meat shops","seafood markets","street vendors","tea rooms","wineries","zapiekanka"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Health & Medical")) {
            String[] toAdd = {"health & medical","acupuncture","cannabis clinics","chiropractors","counseling & mental health","dental hygienists","mobile clinics","storefront clinics","dentists","cosmetic dentists","endodontists","general dentistry","oral surgeons","orthodontists","pediatric dentists","periodontists","diagnostic services","diagnostic imaging","laboratory testing","doctors","allergists","anesthesiologists","audiologist","cardiologists","cosmetic surgeons","dermatologists","ear nose & throat","family practice","fertility","gastroenterologist","gerontologists","internal medicine","naturopathic/holistic","neurologist","obstetricians & gynecologists","oncologist","ophthalmologists","orthopedists","osteopathic physicians","pediatricians","podiatrists","proctologists","psychiatrists","pulmonologist","sports medicine","surgeons","tattoo removal","urologists","hearing aid providers","hearing aids","home health care","hospice","hospitals","lactation services","laser eye surgery/lasik","massage therapy","medical centers","bulk billing","osteopaths","walk-in clinics","medical spas","medical transportation","midwives","nutritionists","occupational therapy","optometrists","pharmacy","physical therapy","reflexology","rehabilitation center","retirement homes","saunas","speech therapists","traditional chinese medicine","urgent care","weight loss centers"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Home Services")) {
            String[] toAdd = {"home services","building supplies","carpenters","carpet installation","carpeting","contractors","electricians","flooring","garage door services","gardeners","handyman","heating & air conditioning/hvac","home cleaning","home inspectors","home organization","home theatre installation","home window tinting","interior design","internet service providers","irrigation","keys & locksmiths","landscape architects","landscaping","lighting fixtures & equipment","masonry/concrete","movers","painters","plumbing","pool cleaners"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Hotel & Travel")) {
            String[] toAdd = {"hotels & travel","airports","bed & breakfast","campgrounds","car rental","guest houses","hostels","hotels","motorcycle rental","rv parks","rv rental","resorts","ski resorts","tours","train stations","transportation","airlines","airport shuttles","dolmus station","ferries","limos","public transportation","taxis","water taxis","travel services","vacation rental agents","vacation rentals"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Local Flavor")) {
            String[] toAdd = {"local flavor"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Local Services")) {
            String[] toAdd = {"local services","appliances & repair","bail bondsmen","bike repair/maintenance","carpet cleaning","child care & day care","community service/non-profit","couriers & delivery services","dry cleaning & laundry","electronics repair","funeral services & cemeteries","furniture reupholstery","it services & computer repair","data recovery","mobile phone repair","jewelry repair","junk removal & hauling","notaries","pest control","printing services","record labels","recording & rehearsal studios","recycling center","screen printing","screen printing/t-shirt printing","self storage","sewing & alterations","shipping centers","shoe repair","snow removal","watch repair","youth club"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Mass Media")) {
            String[] toAdd = {"mass media","print media","radio stations","television stations"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Nightlife")) {
            String[] toAdd = {"nightlife","adult entertainment","bars","beach bars","beer bar","champagne bars","cocktail bars","dive bars","gay bars","hookah bars","hotel bar","irish pub","lounges","pubs","sports bars","wine bars","beer gardens","coffeeshops","comedy clubs","country dance halls","dance clubs","dance restaurants","fasil music","jazz & blues","karaoke","music venues","piano bars","pool halls"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Pets")) {
            String[] toAdd = {"pets","animal shelters","horse boarding","pet services","dog walkers","pet boarding/pet sitting","pet groomers","pet training","pet stores","veterinarians"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Professional Services")) {
            String[] toAdd = {"professional services","accountants","advertising","architects","boat repair","career counseling","editorial services","employment agencies","graphic design","internet service providers","lawyers","bankruptcy law","business law","criminal defense law","dui law","divorce & family law","employment law","estate planning law","general litigation","immigration law","personal injury law","real estate law","life coach","marketing","matchmakers","office cleaning","personal assistants","private investigation","public relations","security services","talent agencies","taxidermy","translation services","video/film production","web design"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Public Services & Government")) {
            String[] toAdd = {"public services & government","authorized postal representative","community centers","courthouses","departments of motor vehicles","embassy","fire departments","landmarks & historical buildings","libraries","police departments","post offices","registry office","tax office"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Real Estate")) {
            String[] toAdd = {"real estate","apartments","commercial real estate","home staging","mortgage brokers","property management","real estate agents","real estate services","shared office spaces","university housing","roofing","security systems","shades & blinds","solar installation","television service providers","tree services","utilities","window washing","windows installation","real estate","apartments","commercial real estate","home staging","mortgage brokers","property management","real estate agents","real estate services","shared office spaces","university housing"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Religious Organizations")) {
            String[] toAdd = {"religious organizations","buddhist temples","churches","hindu temples","mosques","synagogues"};
            groupMembers = addMyMembers(toAdd);
        }
        else if(groupId.equals("Restaurants")) {
            String[] toAdd = {"restaurants","afghan","african","senegalese","south african","american","american","arabian","argentine","armenian","asian fusion","asturian","australian","austrian","baguettes","bangladeshi","barbeque","basque","bavarian","beer garden","beer hall","belgian","bistros","black sea","brasseries","brazilian","breakfast & brunch","british","buffets","bulgarian","burgers","burmese","cafes","cafeteria","cajun/creole","cambodian","canadian","canteen","caribbean","dominican","haitian","puerto rican","trinidadian","catalan","chech","cheesesteaks","chicken shop","chicken wings","chinese","cantonese","dim sum","fuzhou","hakka","henghwa","hokkien","shanghainese","szechuan","teochew","comfort food","corsican","creperies","cuban","curry sausage","cypriot","czech/slovakian","danish","delis","diners","eastern european","ethiopian","fast food","filipino","fish & chips","fondue","food court","food stands","french","french southwest","galician","gastropubs","georgian","german","baden","eastern german","hessian","northern german","palatine","rhinelandian","giblets","gluten-free","greek","halal","hawaiian","himalayan/nepalese","hot dogs","hot pot","hungarian","iberian","indian","indonesian","international","irish","island pub","israeli","italian","altoatesine","apulian","calabrian","cucina campana","emilian","friulan","ligurian","lumbard","roman","sardinian","sicilian","tuscan","venetian","japanese","izakaya","ramen","teppanyaki","jewish","kebab","korean","kosher","kurdish","laos","laotian","latin american","colombian","salvadoran","venezuelan","live/raw food","lyonnais","malaysian","mamak","nyonya","meatballs","mediterranean","mexican","middle eastern","egyptian","lebanese","milk bars","modern australian","modern european","mongolian","moroccan","new zealand","night food","open sandwiches","oriental","pakistani","parent cafes","parma","persian/iranian","peruvian","pita","pizza","polish","pierogis","portuguese","potatoes","poutineries","pub food","rice","romanian","rotisserie chicken","rumanian","russian","salad","sandwiches","scandinavian","scottish","seafood","serbo croatian","signature cuisine","singaporean","soul food","soup","southern","spanish","arroceria / paella","steakhouses","sushi bars","swabian","swedish","swiss food","tabernas","taiwanese","tapas bars","tapas/small plates","tex-mex","thai","traditional norwegian","traditional swedish","turkish","chee kufta","gozleme","turkish ravioli","ukrainian","vegan","vegetarian","venison","vietnamese","wok","wraps","yugoslav"};
            groupMembers = addMyMembers(toAdd);
        }
        else {
            String[] toAdd = {"shopping","adult","antiques","art galleries","arts & crafts","art supplies","cards & stationery","costumes","embroidery & crochet","fabric stores","framing","auction houses","baby gear & furniture","bespoke clothing","books, mags, music & video","bookstores","comic books","music & dvds","newspapers & magazines","videos & video game rental","vinyl records","bridal","chinese bazaar","computers","concept shops","cosmetics & beauty supply","department stores","discount store","drugstores","electronics","eyewear & opticians","fashion","accessories","children's clothing","department stores","formal wear","hats","leather goods","lingerie","maternity wear","men's clothing","plus size fashion","shoe stores","sleepwear","sports wear","surf shop","swimwear","used, vintage & consignment","women's clothing","fireworks","flea markets","flowers & gifts","cards & stationery","florists","flowers","gift shops","golf equipment shops","guns & ammo","hobby shops","home & garden","appliances","furniture stores","hardware stores","home decor","hot tub & pool","kitchen & bath","linens","mattresses","nurseries & gardening","tableware","jewelry","kiosk","knitting supplies","luggage","market stalls","medical supplies","mobile phones","motorcycle gear","musical instruments & teachers","office equipment","outlet stores","pawn shops","perfume","personal shopping","photography stores & services","pop-up shops","scandinavian design","shopping centers","souvenir shops","spiritual shop","sporting goods","bikes","golf equipment","outdoor gear","sports wear","thrift stores","tickets","tobacco shops","toy stores","trophy shops","uniforms","used bookstore","watches","wholesale stores","wigs"};
            groupMembers = addMyMembers(toAdd);
        }
        return groupMembers;
    }


    private ArrayList<Item> addMyMembers(String[] restaurantArray) {
        ArrayList<Item> groupMembers = new ArrayList<Item>();
        for(int i=0; i<restaurantArray.length; i++) {
            Item item = new Item();
            item.name = restaurantArray[i];
            item.id = restaurantArray[i];
            groupMembers.add(item);
        }
        return groupMembers; 
    }
}
...