ArrayAdapter does not update with dynamic data
<p>I am new to Android and I can't find an answer to this that works.</p>

<p>I have the following adapter:</p>

<pre><code>public class DailyDataAdapter extends ArrayAdapter&lt;DailyData&gt; {
    private LayoutInflater layoutInflater;
    private ArrayList&lt;DailyData&gt; dailyDatas;
    private boolean isUserSavedSectionDefined = false;
    private boolean isAutoSavedSectionDefined = false;
    private int resourceId;

    public DailyDataAdapter(Context context, int textViewResourceId,
            ArrayList&lt;DailyData&gt; dailyDatas) {
        super(context, textViewResourceId, dailyDatas);
        this.layoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.dailyDatas = dailyDatas;
        this.resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View dailyDataRow = convertView;

        DailyData dailyData = dailyDatas.get(position);

        if (dailyDataRow == null) {
            dailyDataRow = layoutInflater.inflate(resourceId, null);

            if (!isUserSavedSectionDefined &amp;&amp; dailyData.isUserSaved()) {
                TextView section = (TextView) dailyDataRow
                        .findViewById(R.id.section);
                section.setText(R.string.user_saved_path);
                section.setVisibility(View.VISIBLE);
                isUserSavedSectionDefined = true;
            } else if (!isAutoSavedSectionDefined &amp;&amp; !dailyData.isUserSaved()) {
                TextView section = (TextView) dailyDataRow
                        .findViewById(R.id.section);
                section.setText(R.string.auto_saved_path);
                section.setVisibility(View.VISIBLE);
                isAutoSavedSectionDefined = true;
            }

            TextView description = (TextView) dailyDataRow
                    .findViewById(R.id.description);
            description.setText(dailyData.getDate());
        }
        return dailyDataRow;
    }

    @Override
    public void add(DailyData newDailyData) {
        dailyDatas.add(newDailyData);
    }

    @Override
    public void addAll(Collection&lt;? extends DailyData&gt; newDailyDatas) {
        dailyDatas.addAll(newDailyDatas);
    }

    @Override
    public void insert(DailyData newDailyData, int index) {
        dailyDatas.add(index, newDailyData);
    }

    @Override
    public void remove(DailyData newDailyData) {
        dailyDatas.remove(newDailyData);
    }

    @Override
    public void clear() {
        dailyDatas.clear();
    }
}
</code></pre>

<p>Which inflates the following layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &gt;

&lt;TextView
    android:id="@+id/section"
    android:layout_width="fill_parent"
    android:layout_height="20dp"
    android:layout_marginLeft="50dp"
    android:background="@drawable/listitem_section"
    android:gravity="center"
    android:textColor="@color/white"
    android:visibility="gone"
    android:textStyle="bold" /&gt;

&lt;TextView
    android:id="@+id/description"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:layout_marginLeft="50dp"
    android:background="@drawable/listitem_selector"
    android:gravity="center"
    android:singleLine="true"
    android:textColor="@color/black"
    android:textSize="@dimen/normal_text" /&gt;

&lt;LinearLayout
    android:layout_width="fill_parent"
    android:layout_marginLeft="50dp"
    android:layout_height="1dp"
    android:background="@color/orange" &gt;
&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>Now, the problem is that, if I set the content of the list associated with the adapter prior to associating it with the listView where I pretend to show the information, it works well, as so:</p>

<pre><code>//Step #1
ArrayList&lt;Data&gt; ald = new ArrayList&lt;Data&gt;();
Location l = new Location("test");
Data d = new Data(l);
ald.add(d);

DailyData dd = new DailyData(false);
DailyData dd2 = new DailyData(false);
dd.setDataList(ald);
dd2.setDataList(ald);
dailyDataList.add(dd);
dailyDataList.add(dd2);

//Step #2
arrayAdapter = new DailyDataAdapter(this, R.layout.dailydata_item, dailyDataList);
</code></pre>

<p>But, if I associate the adapter to the listView prior to setting the content of the list (which is the pretended behaviour for the application I'm developing), nothing is shown. (Switching the Steps 1 and 2).
All the data I add is made calling the method <strong>notifyDataSetChanged</strong> afterwards.</p>
