Skip to content Skip to sidebar Skip to footer

Android - Custom Listview Changes While Scrolling?

My listview keeps changing while scrolling. I'm trying to display the messages in 'messages' variable. Everything is fine when i scroll first time. But when i scroll again, the tex

Solution 1:

Try to change your conditions as below to set the values in your TextView. In your below code the all if conditions are same. That does not make any difference.

if(message.sent != null && message.received != null)
    {
        Log.i("adapter","both");
        holder.sent.setText(message.sent);
        holder.received.setText(message.received);
    }
    else if(message.sent != null)
    {
        holder.sent.setText(message.sent);
        //holder.received.setBackground(null);
    }
    else if(message.received != null)
    {
        holder.received.setText(message.received);
        //holder.sent.setBackground(null);
    }

Change it as below:

if(message.sent != null && message.received != null)
    {
        holder.sent.setText(message.sent);
        holder.received.setText(message.received);
    }
    else
    {
        holder.sent.setText("NA");
         holder.received.setText("NA");
    }

Solution 2:

Temproary Solution :

The problem seems to be in the holder and it's use. It works now if i dont use the holder class for performance boost. Although i'm not sure how to use the holder properly.

Solution 3:

I had a similar issue. I had a progress bar in my rows. My problem is that I wasn't resetting the progress bar every time get view was called. You must reset ever asset.

Post a Comment for "Android - Custom Listview Changes While Scrolling?"