Android Question Class CheckList Make text header animate(blink)

microbox

Active Member
Licensed User
Longtime User
Hi, I'm using Infomatix' Class Checklist. The code below is what I'm trying to modify in the class to animate (blink) the label lblB
B4X:
Public Sub AddHeader(Text As String)
    Dim pnlH As Panel: pnlH.Initialize("")
    Dim lblB As Label: lblB.Initialize("")
   Dim cdH As ColorDrawable
    cdH.Initialize(Colors.ARGB(100, 30, 30, 30), 10)
    lblB.Background = cdH
    lblB.Text = "   " & Text
    lblB.TextColor = Colors.Yellow
    lblB.TextSize = 30
    lblB.Typeface = Typeface.DEFAULT_BOLD
    lblB.Gravity = Gravity.CENTER_VERTICAL
    lblB.Gravity = Gravity.Center
    pnlH.AddView(lblB, 0, 0, getWidth, PanelHeight)       
    AddToSV(pnlH, PanelHeight, False)
    PaintBackground(pnlH, False)
End Sub
My trouble is I don't know how/where to access lblB in order to use the function like a.Start(lblB) from main, please give guidance.

Advance thank you for the time
 

microbox

Active Member
Licensed User
Longtime User
This is my attempt to add a blinking header when calling the function(Add header) in the class.
B4X:
' Adds a header
Public Sub AddHeader(Text As String)
    Dim pnlH As Panel: pnlH.Initialize("")   
    Dim lblB As Label: lblB.Initialize("")
    Dim cdH As ColorDrawable
    cdH.Initialize(Colors.ARGB(100, 30, 30, 30), 10)
    lblB.Background = cdH
    lblB.Text = "   " & Text
    lblB.TextColor = Colors.Yellow
    lblB.TextSize = 30
    lblB.Typeface = Typeface.DEFAULT_BOLD
    lblB.Gravity = Gravity.CENTER_VERTICAL
    lblB.Gravity = Gravity.Center
    pnlH.AddView(lblB, 0, 0, getWidth, PanelHeight)       
    AddToSV(pnlH, PanelHeight, False)
    PaintBackground(pnlH, False)   
    If flag2 = True Then
    setLblColor(lblB)
    a1.Start(lblB)
    Return
    flag2 = False
    End If
End Sub
Sub setLblColor(lbl As Label)
   lbl.TextColor = Colors.White  
End Sub
The header blink in good manner every first time called, but when adding more or calling the function it seems to blink all headers not the specific newly added header.
I tried to put a flag2 variable but does not solve the issue.
Hope anyone can help me out.

Thanks in advance
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
I got it! Not really neat coding but it works for my need.
B4X:
Sub FillTheList(Title As String, WithCheckBox As Boolean)
    'Activity.Title = Title     
    Dim Str1,Str2,Str3 As String 
    Dim no As Int
    For i= 0 To z-1    
        no = i     
        Str1 = L.Get(i)
        Str3 = Str1.SubString2(0,1)
        Str2 = Str1.SubString(1)
        no= Str3 + 1
        If  Str1.SubString2(0,1) = srch Then ' check if it's current entry(srch = txtText.Text)
            lst.flag2 = True
            lst.AddHeader( "Window " & no & " " & Str2)    ' AddHeader function with blinking
            lst.flag2 = False
        Else
            lst.AddHeader( "Window " & no & " " & Str2)    ' AddHeader function with no blinking   
        End If      
     
    Next
 
    lst.ResizePanel 
End Sub
Just want to share how I did it...In the Sub FillTheList() I added like a search function within the list. L is a clone list of lst.
 
Upvote 0
Top