2017-06-02 69 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(); 
       } 
      });