Kumakitty
Kumakitty

Reputation: 43

recyclerview reloading items

When I scroll screen, items go invisible, right? When I scroll back, the items reload. such as, ImageLoader shows "showImageOnLoading".

besides, there was something that completely made me stunned. i coded like this below:

List<String> title;
if (title.get(position).equals("")) {
        holder.textview.setVisibility(View.GONE);
    } else {
      holder.textview.setText(title.get(position));
    }

what's interesting was textviews of items were GONE randomly!!! there is only ONE String is "" in title. with scrolling textviews being GONE and presenting again....

Upvotes: 0

Views: 541

Answers (2)

Dhruvi
Dhruvi

Reputation: 1981

Below line can help:

List<String> title;
if (title.get(position).equals("")) {
    holder.textview.setVisibility(View.GONE);
} else {
   holder.textview.setVisibility(View.VISIBLE);
   holder.textview.setText(title.get(position));
}

Upvotes: 0

Brian Hoang
Brian Hoang

Reputation: 1111

Because holder keeps item's view. When string is empty you set textview Gone but you has not set visible again. If you want to avoid reload item. You can set setIsRecyclable(false) for holder.

Upvotes: 2

Related Questions