-2

I am having a listview and each row is having an image, some textviews. Now, some of the rows will not be having some textviews depends upon the conditions in the code. I am using viewHolder for this, so when I am applying condition for visibility, these options get disappear in the rows where they should appear.

How can I achieve this ?

Burak
  • 5,252
  • 3
  • 22
  • 30
user3256822
  • 135
  • 1
  • 7

1 Answers1

0

This is common mistake. You might have added code to hide TextView for certain condition. You have to add code to show TextView if condition is not met.

Eg.

if (condition) {
        textView.setVisibility(View.INVISIBLE);
    } else {
        textView.setVisibility(View.VISIBLE);
    }

This happens because ListView recycles rows to work more efficiently, and faster.

Community
  • 1
  • 1
Paritosh
  • 2,097
  • 3
  • 30
  • 42