There is such a code from which the ExpandableListView is formed:
private void displayList() { // display the list loadData(); // get reference to the ExpandableListView myList = (ExpandableListView) findViewById(R.id.expandableList); // create the adapter by passing your ArrayList data listAdapter = new MyListAdapter(ScrollFolder.this, parentList); // attach the adapter to the list myList.setAdapter(listAdapter); } private void loadData() { ArrayList<ChildRow> childRows = new ArrayList<ChildRow>(); ParentRow parentRow = null; childRows.add(new ChildRow("item 1")); childRows.add(new ChildRow("item 2")); childRows.add(new ChildRow("item 3")); childRows.add(new ChildRow("item 4")); childRows.add(new ChildRow("item 5")); parentRow = new ParentRow("First Group", childRows); parentList.add(parentRow); childRows = new ArrayList<ChildRow>(); childRows.add(new ChildRow("item 6")); childRows.add(new ChildRow("item 7")); childRows.add(new ChildRow("item 8")); childRows.add(new ChildRow("item 9")); childRows.add(new ChildRow("item 10")); parentRow = new ParentRow("Second Group", childRows); parentList.add(parentRow); childRows = new ArrayList<ChildRow>(); childRows.add(new ChildRow("item 11")); childRows.add(new ChildRow("item 12")); childRows.add(new ChildRow("item 13")); childRows.add(new ChildRow("item 14")); childRows.add(new ChildRow("item 15")); parentRow = new ParentRow("Third Group", childRows); parentList.add(parentRow); } Tell loadData how to make the data in loadData were not hard-coded in the code, but could be pulled dynamically? Those. it is necessary that this data could be modified not by changing the application code, but rather being pulled up from some strings.xml or SQL database.
I also assume that you need some kind of cycle that will run through the variables Group and item . Help all realize this correctly?