Android Question Error thrown in changing heights of clv items

Hi all,
I was trying to change the panel heights of CLV items, but the app crashed when loading.

b4x:
Private Sub SetHeightsMaxOfItems(maxheight As Int)
    For i=0 To clv1.Size-1
        Private newPanel As B4XView=clv1.GetPanel(i)
        
        Private newItemValue As Object=clv1.GetValue(i)
        
        Private lblT As B4XView=newPanel.GetView(0)
        Private lblB As B4XView=newPanel.Getview(1)
        
        lblT.Height=maxheight
        lblB.Height=maxheight
        
        newPanel.Height=lblT.Top+lblT.Height+5dip 'change the height of the panel
        
        newPanel.RemoveViewFromParent
        clv1.RemoveAt(i)       
        
        clv1.InsertAt(i,newPanel,newItemValue) 'app crashed on this line
        Log($"item ${i} modified"$)
    Next
    
End Sub


Logger Output:
** Service (starter) Start **
** Activity (main) Create (first time) **
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
Error occurred on line: 159 (ThoughtExhibiter_Cls)
java.lang.IllegalArgumentException: Cannot set 'scaleY' to Float.NaN
    at android.view.View.sanitizeFloatPropertyValue(View.java:17927)
    at android.view.View.sanitizeFloatPropertyValue(View.java:17901)
    at android.view.View.setScaleY(View.java:17287)
    at android.animation.PropertyValuesHolder.nCallFloatMethod(Native Method)
    at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
    at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:692)
    at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:655)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1087)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1106)
    at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
    at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1099)
    at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1149)
    at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1234)
    at android.animation.AnimatorSet.start(AnimatorSet.java:729)
    at android.animation.AnimatorSet.start(AnimatorSet.java:684)
    at anywheresoftware.b4a.objects.B4XViewWrapper.SetLayoutAnimated(B4XViewWrapper.java:180)
    at b4a.example3.customlistview._insertatimpl(customlistview.java:645)
    at b4a.example3.customlistview._insertat(customlistview.java:540)
    at java.lang.reflect.Method.invoke(Native Method)

I would like to know why this error happened and what is the right way to change a panel height.
Thank you very much.
 
I'm just replying in case someone has the same problem.
After several days of testing, I finally found the cause of this error:
I forgot to use the panel.SetLayoutAnimatied() method, when I was adding Items to Clv, prioring to changing the panels' height. That mistake made the value of the CLVItem.size 0 and the app crashed somewhere that needs CLVItem.size as a parameter.😂
 
Upvote 0
Top