J'ai une question sur la façon dont notifyDataSetChanged()
travaille dans un BaseExpandableListAdapter
Comment notifyDataSetChanged fonctionne-t-il?
Je mets à jour une variable booléenne, la sortie détermine la sortie de getChildrenCount()
, mais le nombre de commentaires visibles ne change pas à l'appeler
code :
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;
}
}
Il n'y a pas de changement de données est votre adaptateur. Veuillez indiquer les valeurs "allCommentsVisiable" dans l'adaptateur de données. –
Actuellement, il s'agit d'une variable memeber privée de "public class PostListAdapter extends BaseExpandableListAdapter" –
Autres membres: private Liste postList; Contexte contextuel privé; private String SessionID; –