Why do items disappear when I scroll the listView? Why do items disappear when I scroll the listView? xml xml

Why do items disappear when I scroll the listView?


It's because you're hiding some of your views sometimes, and you never show them again. Example:

        if (!(datapark.get(position).bio.equals(""))){                    holder.bio.setText(datapark.get(position).bio);        }else{          ((TextView)convertView.findViewById(R.id.bio)).setVisibility(View.GONE);        }

instead try:

        if (!(datapark.get(position).bio.equals(""))){           holder.bio.setVisibility(View.VISIBLE);                   holder.bio.setText(datapark.get(position).bio);        }else{          holder.bio.setVisibility(View.GONE);        }

Remember that views are recycled, so, unless you show the views the next time you return one, they will never be visible again. Also, remember that holder.bio is the same thing that is returned by the findViewById, so you can do holder.bio.setVisibility(View.GONE) in the else block.


I had the same problem.

        if (!imageuri.isEmpty()) {            rl.setVisibility(View.VISIBLE);            SmartImageView imageView = (SmartImageView) view.findViewById(R.id.detailimageView1);            imageView.setImageUrl(imageuri);        } else {                        rl.setVisibility(View.GONE);        }

Thanks for the solution!