I'm trying to use the viewholder patter to improve the speed in my listviews. Everything works ok, but I have a problem with the alignment of a TextView. This is the XML of the TextView I'm having problems with:
<TextView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:text="200"
android:textSize="23sp"
android:id="@+id/windAverage"
android:layout_gravity="right"/>
In this textview there is a number, when I reuse a holder which had a number larger than 9 the problem occurs, for example:
There is a row which has 11 in this textview, the user would see "11kn" this is ok because the 11 is close to kn. When the user scrolls and I receive the holder of this row to reuse it and set the text from 11 to 5 for example, the user would see "5 kn" with a white space between the 5 and kn, if the previous value was bigger than 99 it would print 5 kn with two white spaces. It's like it is keeping the reference of the 11 to print the number. Is there a way to set the alignment to it's initial state so it is recalculated to print the new number in it's correct position?