先给出解决方案:
在调用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("回复数据为空!");
}
}
网友评论