@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
ListAdapter 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});
listaptmnt.setAdapter(adapter);
notifysetdatachanged()错误如何设置?
答案 0 :(得分:0)
请使用以下代码修复错误...
adapter.notifyDataSetChanged();
答案 1 :(得分:0)
流程:com.example.guru.pro,PID:14411 java.lang.IllegalStateException:适配器的内容已更改,但ListView未收到通知。确保不从后台线程修改适配器的内容,而只是从UI线程修改。确保适配器在其内容更改时调用notifyDataSetChanged()。 [在ListView(2131558572,类android.widget.ListView)中使用Adapter(类android.widget.SimpleAdapter)] 在android.widget.ListView.layoutChildren(ListView.java:1573) 在android.widget.AbsListView.onLayout(AbsListView.java:2222) 在android.view.View.layout(View.java:15900)
答案 2 :(得分:0)
@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)]
答案 3 :(得分:0)
将你的notifySetDataChanged放在uithread:
中runOnUiThread(new Runnable() {
@Override
public void run() {
adapter. notifysetdatachanged();
}
});