How to use notifyDataSetChanged() in thread

前端 未结 5 1851
醉话见心
醉话见心 2020-12-03 05:00

I create a thread to update my data and try to do notifyDataSetChanged at my ListView.

private class ReceiverThread extends Thread {

@Override
         


        
5条回答
  •  Happy的楠姐
    2020-12-03 05:19

    Use runOnUiThread() method to execute the UI action from a Non-UI thread.

    private class ReceiverThread extends Thread {
    @Override
    public void run() { 
    Activity_name.this.runOnUiThread(new Runnable() {
    
            @Override
            public void run() {
                 mAdapter.notifyDataSetChanged();
            }
        });
    }
    

提交回复
热议问题