Android Question [B4X] [XUI] xCustomListView bug with SetColorAnimated

ivan.tellez

Active Member
Licensed User
Longtime User
If you use the ItemClick event to open another activity, the color of SenderPanel changes to PressedColor and The activity opens, but when second activity closes and the app returns to first Activity, the Item is still with the PressedColor.

This is the code In xCustomListView:

B4X:
Private Sub PanelClickHandler(SenderPanel As B4XView)
    Dim clr As Int = GetRawListItem(SenderPanel.Tag).Color
    SenderPanel.SetColorAnimated(50, clr, PressedColor)
    If xui.SubExists(CallBack, EventName & "_ItemClick", 2) Then
        CallSub3(CallBack, EventName & "_ItemClick", SenderPanel.Tag, GetRawListItem(SenderPanel.Tag).Value)
    End If
    Sleep(200)
    SenderPanel.SetColorAnimated(200, PressedColor, clr)
End Sub


So, aparently if the Activity is changed, the second SetColorAnimated is never executed.

Any idea on how to fix this?


Workaround: add a sleep in the ItemClick to allow the animation to end before start the new Activity.
 
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
Moving the CallSub3 statement to the end of the PanelClickHandler sub solves the problem too.
Like this:
B4X:
Private Sub PanelClickHandler(SenderPanel As B4XView)
    Dim clr As Int = GetRawListItem(SenderPanel.Tag).Color
    SenderPanel.SetColorAnimated(50, clr, PressedColor)
    Sleep(200)
    SenderPanel.SetColorAnimated(200, PressedColor, clr)
    If xui.SubExists(CallBack, EventName & "_ItemClick", 2) Then
        CallSub3(CallBack, EventName & "_ItemClick", SenderPanel.Tag, GetRawListItem(SenderPanel.Tag).Value)
    End If
End Sub

But it's up to @Erel to do this change, I think.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
Moving the CallSub3 statement to the end of the PanelClickHandler sub

It's another workaround. It has just the same problem than mine, we are adding a pause and the user can "feel" the delay between the click and the action. I put my pause outside the xCustomListView because if you have other lists that dont start an activity, those are not afected.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But it's up to @Erel to do this change, I think.
This is not a good change as it will make all these events less responsive.

@ivan.tellez this is not considered a bug. This is how the animation works. Adding Sleep is a possible solution. You can also remove it completely.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
This is how the animation works.

The ListView has the animationand doesn't have this problem, color is changenged to normal state even if the activity changed. So, it should be possible somehow. I'm updating an App on ios and Android, porting all the lists to xCustomListView for easier code sharing. For now, I will use sleep on Android

Thanks
 
Upvote 0
Top