2017-06-02 70 views
-3
@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()错误如何设置?notifysetdatachanged()错误如何设置?

+1

您可以发布错误日志? – Vasant

回答

0

请使用以下代码用于固定错误...

adapter.notifyDataSetChanged();

0

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

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)] 
0

把UR notifySetDataChanged在uithread:

runOnUiThread(new Runnable() { 
       @Override 
       public void run() { 
        adapter. notifysetdatachanged(); 
       } 
      });