title: How to update Android ListView with dynamic data in real time?
body: <p>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 rows in the dataset changes too (but certainly not as often as the data in the cells changes). </p>
  
  <p>There are two ways to update the data in the cells, as far as I can tell:</p>
  
  <ol>
  <li><p>Have the background thread notify the UI thread that new data is ready, and the UI thread can then call BaseAdapter.notifyDataSetChanged().  However, I have read in more than one place that if that method is called often, it will be slow, because the ListView has to restructure all of its subviews Views.</p></li>
  <li><p>If the dataset count has not changed, I could possibly find all of the visible ListView cells that are associated with the changed data, and update the values manually without calling notifyDataSetChanged().  This would probably work, but I think its unfortunate that I have to update the views manually when the List Adapter is supposed to handle the update notifications and mechanisms for me when I notify it.  This method also won't work if the dataset count changes over time (i.e. not only is the data within each cell of the ListView changing, but the total number of cells in the ListView can grow or shrink based on the background thread supplying realtime data).</p></li>
  </ol>
  
  <p>I would certainly appreciate thoughts from others who have implemented this scenario, and how they optimized code simplicity and most importantly, performance.</p>