java.lang.IllegalStateException:适配器的内容已更改,但ListView未收到通知

时间:2017-03-01 08:21:54

标签: android performance listview

* java.lang.IllegalStateException:适配器的内容已更改,但ListView未收到通知。确保不从后台线程修改适配器的内容,而只是从UI线程修改。

1.我的应用程序是使用GPS位置的导航应用程序,标记将根据用户车辆驱动器从源到目标动画,因此一旦获取当前位置,将在同一活动中使用RightsideDrawer listview填充高速公路详细信息:它会自动更新右侧列表视图中的附近商店位置及其详细信息,并使用列表视图中所有列表项的当前位置计算更新距离(在RightNavigationSubViewAdapter -customadapter类中)。

2.每3000ms的位置更新,一次调用CurrentLocationUpdateList 3秒。在更新右侧抽屉子列表视图(用户驾驶时)时,它会在Micromax TAB,Samsung Grand Prime和HTC 4.4.2等移动设备上发生崩溃。驾驶时,只有这些手机在非常罕见的情况下发生碰撞,我需要尽快解决。请帮我解决。

$(document).ready(function(){
    $("#from").datepicker({maxDate:"+6D"});
    $("#to").datepicker({
        onSelect: function () {
            var toDate = $(this).datepicker('getDate');
            toDate.setDate(toDate.getDate()+6)
            $("#from").datepicker("setDate", toDate);
       }
    });
});

3.子列表视图的右侧抽屉布局,当右侧抽屉打开下方功能时,将执行其UpdateRightSideOpenView工作。即Singleton.getInstance()。drawerOpenRightSubList = true。

@Override
public void onLocationChanged(Location location) {
try {
mCurrentLocation = location;
Singleton.getInstance().mCurrentLocation = location;
final LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
if (isMapReady) {
runOnUiThread(new Runnable() {
    @Override
    public void run() {
        try {
            CurrentLocationUpdateList();
        } catch (Exception e) {
            Log.d(TAG_MSG, "Error", e);
            e.printStackTrace();
        }
        checkAlertView();
        updateMarker(mCurrentLocation);
        updateCamera(position);
        updatePolyLine(position);
    }
});
}
} catch (Exception e) {
Log.d(TAG_MSG, "Error", e);
e.printStackTrace();
}
}
4.右侧Subview功能调用,RightNavigationSubViewAdapter用于打开右侧抽屉,RightNavigationViewAdapter用于关闭右侧抽屉,2个适配器用于2个列表视图,一个用于抽屉打开视图,另一个用于抽屉关闭视图,因此openview将获得额外的数据。

public void CurrentLocationUpdateList {
if (Singleton.getInstance().drawerOpenRightSubList) { 
try {
new UpdateRightSideOpenView().execute();                         
}
catch (IllegalStateException e) {
e.printStackTrace();
}
} 
else {
try {
    new UpdateRightSideSubView().execute();
}
catch (IllegalStateException e) {
    e.printStackTrace();
}
}
}

0 个答案:

没有答案