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

前端 未结 4 581

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条回答
  •  -上瘾入骨i
    2020-12-24 10:43

    I faced a very similar situation where I stored the textviews of List View in a Hashmap where each textview had a tag to have it identified. When the streaming data arrived, all I did was post a runnable on the textview after finding the correct one and got them updated in no time. However, though the updates were instantaneous the UI faced a drag and went sluggish as I was updating about 30 textviews per second. I had my Listview in a fragment inside a ViewPager and it seemed the UI thread was all clogged up and blocked when streaming was on. Hence, I strongly advise against manual updating of the Textviews in a Listview as far as User experience and performance of the UI thread is concerned

提交回复
热议问题