【问题标题】:ExpandableListView - How can i print empty message if no childs present?ExpandableListView - 如果没有孩子,我如何打印空消息?
【发布时间】:2016-09-29 06:21:04
【问题描述】:

我正在开发一个具有 ExpandableListActivity 的应用程序。当一个组没有孩子时,我希望它显示一条消息,表明没有孩子在场。

【问题讨论】:

    标签: android expandablelistview expandablelistadapter


    【解决方案1】:
     expandableListView.setOnGroupClickListener(new OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                if(adapter.getChildrenCount(groupPosition)==0) {
                    //show message 
                    return true;
                }
                return false;
            }
        });
    

    【讨论】:

    • 我应该在哪里写这个?
    • java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“int java.util.ArrayList.size()”
    • 在adapter的getChildrenCount中设置空指针检查,如果为空return 0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2012-08-24
    • 2020-09-05
    相关资源
    最近更新 更多