How to connect search filters panel to ArrayList<SomeClass> and display the result in ExpandableListView?

Viewed 46

Well, maybe the title is little bit complicated. I'll try to explain what I need here. I have an ArrayList<PlayerParameters> which stores PlayerParameters class objects and my ExpandableListView displays some String values from this class (name, age, city etc.) I want to filter my items by the values. I've found a tutorial teaching how to create the search panel: https://medium.com/@makkenasrinivasarao1/expandablelistview-with-checkbox-radiobutton-in-android-af9ec9d81ddf. The question is how to connect this panel to my ArrayList and ExpandableListView. This is a piece of code where I put my data to the ExpandableListView.

public void onCallback(ArrayList<PlayerParameters> playersList, ArrayList<String> playersNames) {
                listDataHeader = playersNames;
                String[] listDataHeaderArray = new String[listDataHeader.size()];
                playersNames.toArray(listDataHeaderArray);
                Collections.sort(listDataHeader);
                listDataChild = new HashMap<String, List<String>>();
                HashMap<String, ArrayList<String>> playerInfo = new HashMap<String, ArrayList<String>>();
                for (PlayerParameters j : playersList) {
                    ArrayList<String> infoList = new ArrayList<String>();
                    infoList.add("Nickname: " + j.getNickname());
                    infoList.add("Age: " + j.getAge());
                    infoList.add("City: " + j.getCity());
                    playerInfo.put(j.getName(), infoList);
                }

                for (int i = 0; i < listDataHeader.size(); i++){
                    listDataChild.put(listDataHeader.get(i), playerInfo.get(listDataHeader.get(i)));
                }

                ExpandableListView expListView = view.findViewById(R.id.lvExp);
                listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
                expListView.setAdapter(listAdapter);
                expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

                    @Override
                    public boolean onGroupClick(ExpandableListView parent, View v,
                                                int groupPosition, long id) {

                        return false;
                    }
                });
}
0 Answers
Related