简体   繁体   中英

How to set the default expand limit to 4 for expandablelistview ?

I am working with expandablelistview. I have to expand the group listview to 4 by default. Is it possible to achieve that?.

You can define fixed value in group list-view like below:

private void prepareListData() {
        listDataHeader = new ArrayList<String>();
        listDataChild = new HashMap<String, List<String>>();

        // Adding parent data
        listDataHeader.add("first");
        listDataHeader.add("second");
        listDataHeader.add("third");
        listDataHeader.add("fourth");

        // Adding child data
        List<String> first = new ArrayList<String>();
        first.add("The Shawshank Redemption");
        first.add("The Godfather");
        first.add("The Godfather: Part II");
        first.add("Pulp Fiction");
        first.add("The Good, the Bad and the Ugly");
        first.add("The Dark Knight");
        first.add("12 Angry Men");

        List<String> second = new ArrayList<String>();
        second.add("The Conjuring");
        second.add("Despicable Me 2");
        second.add("Turbo");
        second.add("Grown Ups 2");
        second.add("Red 2");
        second.add("The Wolverine");

        List<String> third = new ArrayList<String>();
        third.add("2 Guns");
        third.add("The Smurfs 2");
        third.add("The Spectacular Now");
        third.add("The Canyons");
        third.add("Europa Report");

        listDataChild.put(listDataHeader.get(0), first); // Header, Child data
        listDataChild.put(listDataHeader.get(1), second);
        listDataChild.put(listDataHeader.get(2), third);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM