Why did the ListView repeated every 6th item?

@Override
public View getView(int pos, View convertView, ViewGroup parent) {

    if(convertView == null){
        convertView = mLayoutInflater.inflate(zeilen_Layout, null);

        //Assignment code
    }
    return convertView;
}

The reason this is happening is because of how you’ve defined this method (which is getView()). It only modifies the convertView object if it is null, but after the first page of items is filled Android will start recycling the View objects. This means that i.e. the seventh one that gets passed in is not null – it is the object that scrolled off the top of the screen previously (the first item).

The conditional causes you just return what was passed in to the method so it appears to repeat the same 6 items over and over.

Leave a Comment