Android notifysetdatachanged()错误如何设置?

Android notifysetdatachanged()错误如何设置?,android,Android,notifysetdatachanged()错误如何设置?请使用以下代码修复错误 adapter.notifyDataSetChanged() 进程:com.example.guru.pro,PID:14411 java.lang.IllegalStateException:适配器的内容已更改,但ListView未收到通知。确保适配器的内容不是从后台线程修改的,而是仅从UI线程修改的。确保适配器在其内容更改时调用notifyDataSetChanged()。[在ListView(21315585

notifysetdatachanged()错误如何设置?

请使用以下代码修复错误


adapter.notifyDataSetChanged()

进程:com.example.guru.pro,PID:14411 java.lang.IllegalStateException:适配器的内容已更改,但ListView未收到通知。确保适配器的内容不是从后台线程修改的,而是仅从UI线程修改的。确保适配器在其内容更改时调用notifyDataSetChanged()。[在ListView(2131558572,类android.widget.ListView)中,使用适配器(类android.widget.simpledapter)] 位于android.widget.ListView.layoutChildren(ListView.java:1573) 在android.widget.AbsListView.onLayout(AbsListView.java:2222)
在android.view.view.layout(view.java:15900)

将您的notifySetDataChanged放入uithread:

@Override
protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    final SimpleAdapter adapter = new SimpleAdapter(Appointments.this, contactListpnt,R.layout.appointmentlist, abc,new int[]{R.id.tpatientapt, R.id.tphnapt, R.id.tdateapt, R.id.ttymapt, R.id.ttypep, R.id.tstatusp, R.id.tflwupsp, R.id.tnotesp});

    adapter.notifyDataSetChanged();
    listaptmnt.setAdapter(adapter);
}


Process: com.example.guru.pro, PID: 17971
    java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131558572, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)]

你能发布错误日志吗?
@Override
protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    final SimpleAdapter adapter = new SimpleAdapter(Appointments.this, contactListpnt,R.layout.appointmentlist, abc,new int[]{R.id.tpatientapt, R.id.tphnapt, R.id.tdateapt, R.id.ttymapt, R.id.ttypep, R.id.tstatusp, R.id.tflwupsp, R.id.tnotesp});

    adapter.notifyDataSetChanged();
    listaptmnt.setAdapter(adapter);
}


Process: com.example.guru.pro, PID: 17971
    java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131558572, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)]
runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    adapter. notifysetdatachanged();
                }
            });