Android Question Default size for item for customlistview

netsistemas

Active Member
Licensed User
Longtime User
i view to resize the item

sample (not very util) :
B4X:
CLCalendario.ResizeItem(CLCalendario.Size-1,CLCalendario.Size * 1.1)

but,
how set the size for all item or best, set size before add items.

that is: no resize items one by one.
 

netsistemas

Active Member
Licensed User
Longtime User
Ok. I change the code to load a layout and one label control into. This label control are setting with a CSBUILDER (intead of text)
The layout height are defined by LABEL into Layout. ( p.Height = lblDiaCalendario.Height )
i think, that this so correct.
Thanks again.

B4X:
Sub CreateListItem(Text As CSBuilder, Width As Int, Height As Int) As Panel

    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("LayoutFichajesConsultarItem")
    p.Height = lblDiaCalendario.Height
    lblDiaCalendario.Text = Text
    Return p
End Sub

for other user in forum, i put the code woith csbuilder, font, align,colors, etc..

B4X:
Dim Cs1 As CSBuilder
            Dim MM As String
            Cs1.Initialize.Typeface(Typeface.MONOSPACE).Size(20).Alignment("ALIGN_CENTER")
            
            Dim Txt As String
            Cs1.Size(18)
            Txt = Fecha & " " & modGeneral.left(DiaSem,3)
            If Festividad <> "" Then
                Txt = Txt & " - " & Festividad
            Else if TipoPermiso <> "" Then
                Txt = Txt & " - " & TipoPermiso
            End If
            If HATrabajar <> 0 Or HFichadas <> 0 Then
                Txt = Txt & Tam(HATrabajar,5) & " h." & Tam(HFichadas,5) & " h."
            End If
            MM = ""
        
            If Fecha = FechaHoy Then
                Hoy = Reg
                Cs1.Color(Colors.Cyan  )
            ELSE IF HATrabajar = 0 Then
                Cs1.Color(Colors.Yellow )
            ELSE IF HFichadas > HATrabajar  Then
                MM= Chr(0xE145) '"+"
                Cs1.Color(Colors.Magenta  )
            ELSE IF HFichadas < HATrabajar Then
                Cs1.Color(Colors.RED )
                MM  = Chr(0xE909) '"-"
'            Else If DiaSem.StartsWith("D") Then
'                Cs1.Color(Colors.Yellow)
'            Else if DiaSem.StartsWith("S") Then
'                Cs1.Color(Colors.Yellow)
'            else if Festividad <> "" Then
'                Cs1.Color(Colors.Blue)
            End If
            
            
            Cs1.Append(Txt).PopAll
            If MM <> "" Then
                Cs1.Typeface(Typeface.MATERIALICONS).Size(22).Append(MM).PopAll
            End If
            
            'CLCalendario.AddTextItem( Cs1,Fecha)
            'CLCalendario.ResizeItem(CLCalendario.Size-1,CLCalendario.GetBase.Height / 8)
            CLCalendario.Add(CreateListItem(Cs1,  CLCalendario.AsView.Width,20dip), Fecha)
this is tam funcion:
B4X:
private Sub Tam(T As String, Tama As Long) As String
    Dim X As String
    'be carefoul: max tama must be minor than spaces.'

    x= Right("             " & t,Tama)

    Return x
End Sub

public Sub Right( Texto As String, Tama As Long  ) As String
    If Texto.Length > Tama Then
        Return Texto.SubString2( Texto.Length-Tama, Texto.Length)
    Else
        Return Texto
    End If
End Sub
 
Upvote 0
Top