Android Question FadeOut Animation and Remove View

swabygw

Active Member
Licensed User
Longtime User
I have items (panels) within a scrollview that I'd like to have fade out and, then, remove from the scrollview. For example:

B4X:
Dim anim As Animation
anim.InitializeAlpha("itemAnim", 1, 0)
p.Tag = anim 'p is the panel
anim.Duration = 1000
anim.Start(p)

And, then, on the AnimationEnd event:

B4X:
Private Sub itemAnim_AnimationEnd
 Dim s As Animation = Sender
 Dim removePanel As Panel = ???
 removePanel.RemoveView
End Sub

My thinking was to use the Sender ("s" in the above code) to get the panel and remove it. Is there a way to get the panel that the Animation is associated with? Or, maybe there's a better way to get the same effect of fading to removal?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is a good place to use CallSubPlus: CallSubPlus - CallSub with explicit delay

In Starter service:
B4X:
Sub Process_Globals
   Public csu As CallSubUtils
End Sub

Sub Service_Create
   csu.Initialize
End Sub

Main activity:
B4X:
Sub Globals
   Dim panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
End Sub

Sub Panel1_Click
   panel1.SetVisibleAnimated(1000, False)
   Starter.csu.CallSubDelayedPlus2(Me, "Remove_Panel", 1000, Array(panel1))
End Sub

Sub Remove_Panel(args() As Object)
   Dim p As Panel = args(0)
   p.RemoveView
End Sub
 
Upvote 0

swabygw

Active Member
Licensed User
Longtime User
Exactly right. Just curious - is there a B4i equivalent for SetVisibleAnimated and/or CallSubDelayedPlus2?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…