For example I have my custom ExpandableListAdapter extends BaseExpandableListAdapter, it has two groups.
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;
}
First question: Why this code will always return in LogCat Index = 1, Index = 2, Index = 3, … , Index = 10?
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;
}
Second question: 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 convertView = infalInflater.inflate(R.layout.rowgroup, parent, false); line and I saw that getGroupView with groupPosition==0 executed at the beginning and at the end.
It is my mistake or so it should be? I want to understand why this’s happening =)
Thanks for the answers!
I think that I found the answer here =) Before that I do not understand how it works.