How to refresh ListView on login in android
3 answers
You actually have to do two things: - you have to ask the adapter to notify the ListView of new data changes: notifyDataSetChanged () but this will take effect the next time the ListView needs to show the view (say after the scroll list). Another problem is that the ListView won't ask for the number of rows in the list, so if the list gets shorter, you'll get a null pointer exception :)
I prefer to use something like:
if(filterProvider.containsChildren(position)){
// go into the hierarchy
filterProvider.navigateToChildren(position);
adapter.notifyDataSetChanged();
adapter.notifyDataSetInvalidated();
listView.invalidateViews();
}else{
int ID = (int)filterProvider.getIdFromPosition(position);
activity.setResult(ID);
activity.finish();
}
The code is part of a multilevel list (with hierarchy)
Hello Sasha Rudan
0
source to share