Android评论回复 布局 遇见的坑 BaseExpandableListAdapter刷新数据

先给出解决方案:

在调用notifyDataSetChanged()后,使用一下方法收缩一次。

// i 为更新的子view的position,如果全部更新,遍历全部子view

* resultsListView.collapseGroup(i); //收起

* resultsListView.expandGroup(i); //展开

* 两个方法后,数据才能在界面上正常刷新

代码中的用法:

public void addTheReplyData(CommentExpandableListView expandableListView, ReplyDetailBean replyDetailBean, int groupPosition){

if(replyDetailBean!=null){

Log.e("yuan", "该刷新回复列表了:getReplyList = "+commentBeanList.get(groupPosition).getReplyList());

        if(commentBeanList.get(groupPosition).getReplyList() !=null ){

Log.e("yuan", "addTheReplyData: >>>>>replyList不为空 size = "+commentBeanList.get(groupPosition).getReplyList().size() );

            commentBeanList.get(groupPosition).getReplyList().add(replyDetailBean);

        }else {

Log.e("yuan", "addTheReplyData: >>>>>replyList为空 " );

            List replyList =new ArrayList<>();

            replyList.add(replyDetailBean);

            commentBeanList.get(groupPosition).setReplyList(replyList);

        }

notifyDataSetChanged();

        //

        for(int i =0; i

expandableListView.expandGroup(i);

        }

//

    }else {

throw new IllegalArgumentException("回复数据为空!");

    }

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容