我尝试使用notifyDataSetChanged()刷新我的listview,但它被标记为红色。我使用像扩展适配器ListView,所以notifyDataSetChaned它应该工作,但否则。如何使用BaseAdapter刷新我的ListView
下面是我的声明ListView和ArrayList。
ListView listview;
ArrayList<ListData> myList = new ArrayList<>();
设置我的列表中这样说:
listview = (ListView) findViewById(R.id.listView);
listview.setAdapter(new MyBaseAdapter(this, myList));
我也setOnScrollListener使用,我想我的列表视图它时刷新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) {
}
});
也许你应该检查你的导入的包名是你的扩展列表视图。 –