title: Android ListView not updating with changes to adapter
body: <p>I am having trouble with an update to the data in an ArrayAdapter in a ListView and even on listAdapter.notifyDataSetChanged() the changes are not being reflected in the ListView. </p>
  
  <p>Whats interesting is that the initial load is fine, i get the full list of data rendered in the ListView. It is when i load the activity for the second time, where the cached ArrayList gets passed to the setDataList() method doesn't get rendered. The resulting ListView only contains the single default entry setup in the onCreate() method. </p>
  
  <p>I have debugged the code and stepped through the runnable and it appears to run as i would have expected, just without the end result. </p>
  
  <p>If anyone could help with this i would really appreciate it, i have googled it to death!</p>
  
  <p>My code snippets:</p>
  
  <pre><code>public class CriteriaOriginIncludeActivity extends Activity {   
  
  private CriteriaOriginIncludeController m_controller;
  private CriteriaOriginIncludesAdapter m_listAdapter;
  private ArrayList&lt;OriginRowData&gt; m_listData;
  private ListView m_originList;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.criteria_origin_includes);      
      ArrayList&lt;OriginRowData&gt; list = new ArrayList&lt;OriginRowData&gt;();
      list.add(new OriginRowData(new Origin(0,""), false));
  
      m_listAdapter = new CriteriaOriginIncludesAdapter(this,
                                                                  R.layout.origin_include_list_row,
                                                                  R.id.lst_origin_include,
                                                                  list);
  
      m_originList = (ListView) this.findViewById(R.id.lst_origin_include);
      m_originList.setAdapter(m_listAdapter);
  
      m_controller = new CriteriaOriginIncludeController(this);
  
  }
  
  public void setOriginList(ArrayList&lt;OriginRowData&gt; list) {
  
      if (list != null &amp;&amp; list.size() &gt; 0) {
          m_listData = list;
      } else {
          m_listData = new ArrayList&lt;OriginRowData&gt;();
      }
  
      runOnUiThread(returnRes);
  }
  
  private Runnable returnRes = new Runnable() {
  
  public void run() {
  
      m_listAdapter.clear();
      if(m_listData != null &amp;&amp; m_listData.size() &gt; 0){
          m_listAdapter.notifyDataSetChanged();
          for(int i=0;i&lt;m_listData.size();i++)
              m_listAdapter.add(m_listData.get(i));
      }
      m_listAdapter.notifyDataSetChanged();
  }
  };
  }
  </code></pre>
  
  <p>And the adapter:</p>
  
  <pre><code>public class CriteriaOriginIncludesAdapter extends ArrayAdapter&lt;OriginRowData&gt; {
  private ArrayList&lt;OriginRowData&gt; m_items;
      private Context m_context;
  
      public CriteriaOriginIncludesAdapter(Context context, int resourceId, int           textViewResourceId, ArrayList&lt;OriginRowData&gt; list) {
        super(context, resourceId, textViewResourceId, list);
        this.m_context = context;
        m_items = list;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
          LayoutInflater vi = (LayoutInflater)m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          v = vi.inflate(R.layout.origin_include_list_row, null);
        }
        OriginRowData o = m_items.get(position);
        if (o != null) {
          TextView txtName = (TextView) v.findViewById(R.id.txt_origin_include_name);
          TextView txtId = (TextView) v.findViewById(R.id.txt_origin_include_id);
          CheckBox chkOrigin = (CheckBox) v.findViewById(R.id.chk_origin);
  
          if (txtName != null) {
            txtName.setText(o.getOrigin().getOrigin());                            
          }
          if (txtId != null) {
            txtId.setText(Integer.toString(o.getOrigin().getId()));                            
          }
          if (chkOrigin != null) {
            chkOrigin.setChecked(o.getInclude());
  
            chkOrigin.setOnClickListener(new OriginIncludeOnClickListener(position));
          }
  
        }
  
        return v;
     }
  
  }
  </code></pre>