找了很久的解决方案,所以想记录下
Android Studio
如何让SimpleAdapter显示更新后的数据,以下面这个为例:
SimpleAdapter listItemAdapter = new SimpleAdapter(this,
playerData,
R.layout.activity_item,
new String[]{"rank","userName","score","time"},
new int[]{R.id.rank,R.id.userName,R.id.score,R.id.time});
//添加并且显示
list.setAdapter(listItemAdapter);
传入SimpleAdapter的数据playerData,是不能在更新数据后重新再new 一个,再把playerData 赋值为那个新new的List,因为下面这些通知操作,是基于最开始创建SimpleAdapter我new的那个playerData
listItemAdapter.notifyDataSetChanged();
list.invalidateViews(); //listView刷新