TextView scrolling is resetting when I update a different TextView from the same ListView row
Asked Answered
B

1

5

I have a listview and for a specific item I'm refreshing the remaining time every second. It works fine, but I'm having a small bug. Whenever I call

duration.setText(newRemainingValue);

to update the value, another textView from the same row is impacted. This other textVewi displays a scolling text

title.setSelected(true);
title.setEllipsize(TruncateAt.MARQUEE);

and whenever I change the 1st textView value, the second one resets the scrolling and starts scrolling from the beginning. It looks like this issue is only present when I do this in a ListView

Any idea how to fix this ?

Biestings answered 3/2, 2015 at 18:5 Comment(2)
could you post your codeAsaph
I posted the useful code from the adapter. Basically I just want to know if it's an Android bug and if there's a workaround for this issueBiestings
B
10

It sounds like the textviews are set to wrap_content. That will trigger a layout pass whenever the text is changed. Try using match_parent or setting the width and height to a fixed value, so that changing the text will not trigger a layout pass

Breadthways answered 3/2, 2015 at 18:48 Comment(3)
You're totally right ! Setting a fixed width for the TextView I'm updating fixed the issue. Thanks a lot ! Is there by any chance another way to prevent this from happening if I keep a wrap_content width ? Maybe by subclassing TextView and overriding some function ?Biestings
This is realy helpful. You saved my life. Thank you.Tribromoethanol
Wow this fixed a textview i have on a fragment in a tab too. I used the textview for diagnostics for an asynchronous https post the uithread update cut off the last part of the string. Really a great solution.Lewislewisite

© 2022 - 2024 — McMap. All rights reserved.