我對如何notifyDataSetChanged()
作品在BaseExpandableListAdapter
notifyDataSetChanged如何工作?
我更新一個布爾變量的一個問題,它的輸出決定了getChildrenCount()
的輸出,但可見在調用它
代碼不會改變的評論的數量:
buttonViewComments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
allCommentsVisible = !allCommentsVisible;
notifyDataSetChanged();
}
});
getChildrenCount:
public int getChildrenCount(int groupPosition) {
if(allCommentsVisible || postList.get(groupPosition).commentListSize()<=3)
return postList.get(groupPosition).commentListSize();
else{
return 3;
}
}
您的適配器沒有數據更改。請在數據適配器內提供「allCommentsVisiable」值。 –
目前它是一個私人memeber變量的「公共類PostListAdapter擴展BaseExpandableListAdapter」 –
其他成員:私人列表 postList; 私人上下文上下文; private String SessionID; –