Android Question [SOLVED ]How to animate CustomListView item

stanks

Active Member
Licensed User
Longtime User
with fade-in and fade-out effect in a loop? (i still don't have any code)

Thanks
 

stanks

Active Member
Licensed User
Longtime User
CustomListView item Erel. for example i want to fadein/fadeout one item. let's say that this is item with index 30.
or if it is easier at least imageview control which i have in this customlistview item. so i guess i have to fadein/fadeout panel with index 30 or imageview in that panel with index 30 in clv.

thanks
 
Last edited:
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Thanks for the help. I am using this until the "View Guy" shows the better method:
B4X:
Private Sub AnimatePanel(xlv As CustomListView, Duration As Int, Content As Object, Height As Int, Color As Int, TextColor As Int) As ResumableSub
    LogSub("AnimatePanel:  Duration = " & Duration & "  BackgroundColor = " & Color)
    LogSub("Content = " & Content)
    
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0,0,0,xlv.AsView.Width, Height)
    p.SetColorAnimated(0, xui.Color_White, Color)
        
    Dim lbl As Label
    lbl.Initialize("")
    Dim xlbl As B4XView = lbl
    xlbl.SetLayoutAnimated(0,0,0,p.Width,p.Height)
    xlbl.SetTextAlignment("CENTER","LEFT")
    xlbl.TextColor = TextColor
    xlbl.Text = Content
    p.AddView(xlbl,0,0,p.Width,p.Height)

    xlv.Add(p,0)
    
    p = xlv.GetPanel(xlv.Size-1)
    p.Visible = False     '     this was important - thought SetVisibleAnimated took care of that
    p.SetVisibleAnimated(Duration, True)
    
    ''Log("Animate Wait")
    Sleep(Duration)
    
    Return True
    
End Sub
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Thanks for the help. I am using this until the "View Guy" shows the better method:
B4X:
Private Sub AnimatePanel(xlv As CustomListView, Duration As Int, Content As Object, Height As Int, Color As Int, TextColor As Int) As ResumableSub
    LogSub("AnimatePanel:  Duration = " & Duration & "  BackgroundColor = " & Color)
    LogSub("Content = " & Content)
  
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0,0,0,xlv.AsView.Width, Height)
    p.SetColorAnimated(0, xui.Color_White, Color)
      
    Dim lbl As Label
    lbl.Initialize("")
    Dim xlbl As B4XView = lbl
    xlbl.SetLayoutAnimated(0,0,0,p.Width,p.Height)
    xlbl.SetTextAlignment("CENTER","LEFT")
    xlbl.TextColor = TextColor
    xlbl.Text = Content
    p.AddView(xlbl,0,0,p.Width,p.Height)

    xlv.Add(p,0)
  
    p = xlv.GetPanel(xlv.Size-1)
    p.Visible = False     '     this was important - thought SetVisibleAnimated took care of that
    p.SetVisibleAnimated(Duration, True)
  
    ''Log("Animate Wait")
    Sleep(Duration)
  
    Return True
  
End Sub

07.15.22 Above is already stinky. This is better:

B4X:
Private Sub AnimatePanelText(xlv As CustomListView, _
                         WaitAfter As Int, _
                         Content As String, _
                         Height As Int, _
                         Color As Int) As ResumableSub

    LogSub("AnimatePanel:  Content = " & Content)
   
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0,0,0,xlv.AsView.Width, Height)
    p.SetColorAnimated(0, xui.Color_Transparent, Color)
   
    '    1. Create a layout with BBCodeView.
    '    2. Initialize a BCTextEngine object. This should be called after the BBCodeViews And BBLabels were added.
    p.LoadLayout("pnlBCEngine")
    TextEngine.Initialize(p)
    BBCodeView1.Text = Content

    xlv.Add(p, xlv.Size)    '     unique at least
   
    p = xlv.GetPanel(xlv.Size-1)
    p.Visible = False
    p.SetVisibleAnimated(WaitAfter, True)
   
    If xui.IsB4J Then
        Sleep(0)
    Else
        Sleep(WaitAfter)
    End If
   
    Return True
   
End Sub
 
Upvote 0
Top