我正在使用expandablelistview。我必须默认将组listview扩展为4。有可能实现这一目标吗?

最佳答案

您可以在组列表视图中定义固定值,如下所示:

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

关于java - 如何将expandablelistview的默认扩展限制设置为4?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33522122/

10-12 02:02