The problem is with setVisibility calls in code.
if(position==64||position==57||position==58||position==59||position==50||position==23||position==16||position==17||position==9||position==10||position==12||position==1||position==2||position==8) { view.txtViewTitle.setVisibility(View.GONE); view.imgViewFlag.setVisibility(View.GONE); }
You install them in GONE when you do not need them, but you do not install them in VISIBLE when you need them. Once you set the value to GONE, the same cells will be reused when scrolling. At this point, if you do not set them to VISIBLE, they will never appear.
if(position==64||position==57||position==58||position==59||position==50||position==23||position==16||position==17||position==9||position==10||position==12||position==1||position==2||position==8) { view.txtViewTitle.setVisibility(View.GONE); view.imgViewFlag.setVisibility(View.GONE); } else { view.txtViewTitle.setVisibility(View.VISIBLE); view.imgViewFlag.setVisibility(View.VISIBLE); }
To address the second part of the title, you can add a TextView for the title to each cell, but just set its visibility to VISIBLE if this is the first element in the row. This way you do not have to do too much custom code.
Hope this helps.
source share