Android: How ListView works
<p>For example I have my custom ExpandableListAdapter extends BaseExpandableListAdapter, it has <strong>two</strong> groups.</p>

<pre><code>    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent) {
        if (convertView == null) {
            convertView = infalInflater.inflate(R.layout.rowgroup, parent, false);
        }
        s++;
        Log.d("Index", String.valueOf(s));
        return convertView;
    }
</code></pre>

<p><strong>First question:</strong> Why this code will always return in LogCat Index = 1, Index = 2, Index = 3, ... , Index = 10?</p>

<pre><code>public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent) {
        if (convertView == null) {
            s++;
            Log.d("Index", String.valueOf(s));
            convertView = infalInflater.inflate(R.layout.rowgroup, parent, false);
        }
            return convertView;
        }
</code></pre>

<p><strong>Second question:</strong> Why this code will return in LogCat Index = 1, Index = 2, Index = 3? I have only 2 groups, not 3. If I add one more group, the Index value will be 4. I set breakpoint in <strong>convertView = infalInflater.inflate(R.layout.rowgroup, parent, false);</strong> line and I saw that getGroupView with <em>groupPosition==0</em> executed at the beginning and at the end.</p>

<p>It is my mistake or so it should be? I want to understand why this's happening =)</p>

<p>Thanks for the answers!</p>
