标签:lis nbsp route dal 不刷新 div date logs result
private List<Navi> mRouteList;
1. 设置Adapter
private void initData() { mRouteList = new ArrayList<Route>(); mRouteList.clear(); mAdapter = new CarRouteAdapter(getActivity(), mRouteList); mListView.setAdapter(mAdapter); }
2. 获取数据,刷新listview
private void updateRoutes(List<MtqCarRoute> listOfResult) {
mRouteList.clear();
mRouteList = CarUtils.formatNaviRoutes(listOfResult);
mAdapter.notifyDataSetChanged();
}
发现这样做,listview的数据已经发生变化,但是就是没有更新。
解决如下:
private void updateRoutes(List<MtqCarRoute> listOfResult) { mRouteList.clear(); // mRouteList = CarUtils.formatNaviRoutes(listOfResult); mRouteList.addAll(CarUtils.formatNaviRoutes(listOfResult)); mAdapter.notifyDataSetChanged(); }
android ListView中使用notifyDataSetChanged()不刷新
标签:lis nbsp route dal 不刷新 div date logs result
原文地址:http://www.cnblogs.com/zhaoqingyue/p/6785239.html