Developing my very first app I'm trying to add sections to my elements in a list view. All items a have a date and I want to return a simple layout containing a date each time the date changes. In my adapter I have the following:
    public View getView(int position, View convertView, ViewGroup parent) {
    Match match = matchArrayList.get(position);
    Calendar matchTime = match.getDate();
    SimpleDateFormat date = new SimpleDateFormat("dd-MM-yyyy");
    SimpleDateFormat time = new SimpleDateFormat("HH:mm"); 
    String sDate = date.format(matchTime.getTime());
    SeparatorHolder separatorHolder = null;
    MatchHolder matchHolder = null;
    if (convertView == null) {
        if (!sDate.equals(_lastDate)) {
            convertView = inflator.inflate(R.layout.date_separator, null);
            separatorHolder = new SeparatorHolder();
            separatorHolder.Date = (TextView) convertView.findViewById(R.id.date);
            convertView.setTag(separatorHolder);
        } else {
            convertView = inflator.inflate(R.layout.match_layout, null);
            matchHolder = new MatchHolder();
            matchHolder.Time = (TextView) convertView.findViewById(R.id.time);
            matchHolder.HomeTeam = (TextView) convertView.findViewById(R.id.homeTeam);
            matchHolder.AwayTeam = (TextView) convertView.findViewById(R.id.awayTeam);
            matchHolder.HomeTeamImage = (ImageView) convertView.findViewById(R.id.homeTeamImageView);
            matchHolder.AwayTeamImage = (ImageView) convertView.findViewById(R.id.awayTeamImageView);
            matchHolder.TournamentImage = (ImageView) convertView.findViewById(R.id.tournamentImageView);
            matchHolder.TVChannelImage = (ImageView) convertView.findViewById(R.id.tvChannelImageView);
            convertView.setTag(matchHolder);
        }
    } 
    else {
        if (!sDate.equals(_lastDate)) 
            matchHolder = (MatchHolder) convertView.getTag();
        else
            separatorHolder = (SeparatorHolder) convertView.getTag();
    }
    if (!sDate.equals(_lastDate)) {
        _lastDate = sDate;
        separatorHolder.Date.setText(sDate);
    } else {
        UrlImageViewHelper.setUrlDrawable(matchHolder.TournamentImage, match.getTournamentImage());
        UrlImageViewHelper.setUrlDrawable(matchHolder.HomeTeamImage, match.getHomeTeamImage());
        matchHolder.HomeTeam.setText(match.getHomeTeam());
        UrlImageViewHelper.setUrlDrawable(matchHolder.AwayTeamImage, match.getAwayTeamImage());
        matchHolder.AwayTeam.setText(match.getAwayTeam());
        matchHolder.Time.setText(time.format(matchTime.getTime()));
        UrlImageViewHelper.setUrlDrawable(matchHolder.TVChannelImage, match.getTVChannelImage());
    }
    return convertView;
}
Everything works just fine until I reach the very last line:
return convertView;
Adding a break point to that line and trying to step passed it immediately throws some sort of error.
Now being new to Android and Eclipse I really can't find a stacktrace similar to what I get when coding .Net in Visual Studio. All I can see is that in the Debug perspective in Eclipse a tab with AbsListView.class is opened...
Can anyone make any sense of what I'm trying to achieve? And maybe help out a bit? I looked at this link and as far as I can tell he also returns two different views depending on item type :-?
Edit: Implemented Streets Of Bostons answer and changed the code to
@Override
public int getItemViewType(int position) {
    Match match = matchArrayList.get(position);
    if (match.HomeTeam == "") {
        return 0;
    }
    else {
        return 1;
    }
}
Now it works but scrolling in my list FC's my app
Thanks in advance
 
     
     
     
    