How to update Android ListView with dynamic data in real time?

前端 未结 4 564

I have a background thread loading data which I want to display in an Android ListView. The data changes very often (i.e. 1-2 times per second). Sometimes the number of ro

4条回答
  •  囚心锁ツ
    2020-12-24 10:57

    Maybe you can set a Handler on the UI thread. You need to create a class which implements Runnable. Pass an ArrayList to this class. In the run() method create the adaptor with the ArrayList as a parameter, then do a setAapter on the ListView. That's it. You're done. To launch your handler : just to this from your worker thread : handler.Post(new MyUpdateToUI() ); That's it. I hope it is efficient enough for you?

提交回复
热议问题