I tried refresh my listview using notifyDataSetChanged() but this is marked on red. I use ListView like extended Adapter so notifyDataSetChaned it should work but is otherwise.
Below is my declaration ListView and ArrayList.
ListView listview;
ArrayList<ListData> myList = new ArrayList<>();
I set up my list in this way:
listview = (ListView) findViewById(R.id.listView);
listview.setAdapter(new MyBaseAdapter(this, myList));
I use also setOnScrollListener and I want that my listview it refresh when SROLL_STATE = 0;
listview.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
int position = listview.getFirstVisiblePosition();
SCROLL_STATE = position;
if (SCROLL_STATE == 0) {
listview.notifyDataSetChanged(); // Here is a problem, because it's not work
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
Define a Adapter object, MyBaseAdapter adapter=new MyBaseAdapter(this, myList); adapter.notifyDataSetChanged();