Hello,
As a beginner I was playing with CLV expandable and I'm trying to use only 3 expandebles and put a different image to each.
I think I'm close as the image get downloaded but not placed. Search many example and tried. I must be doing something wrong.
How can to do this correct?
As a beginner I was playing with CLV expandable and I'm trying to use only 3 expandebles and put a different image to each.
I think I'm close as the image get downloaded but not placed. Search many example and tried. I must be doing something wrong.
How can to do this correct?
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Private clv1 As CustomListView
Private lblTitle As B4XView
Private pnlTitle As B4XView
Private pnlExpanded As B4XView
Private xui As XUI
Private expandable As CLVExpandable
Private TrkImage1 As ImageView
Private TrkImage2 As ImageView
Private TrkImage3 As ImageView
Private ImageView2 As ImageView
Public lnk1 As String
Public lnk2 As String
Public lnk3 As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
expandable.Initialize(clv1)
'For i = 1 To 20
'Dim p As B4XView = CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i, 300dip + 60dip)
'clv1.Add(p, expandable.CreateValue(p, "some value"))
'Next
TrkImage1.Initialize("")
TrkImage2.Initialize("")
TrkImage3.Initialize("")
'lnk1 = "https://b4x-4c17.kxcdn.com/images3/android.png"
'lnk2 = "https://b4x-4c17.kxcdn.com/images3/apple.png"
'lnk3 = "https://b4x-4c17.kxcdn.com/images3/hp.png"
DownloadImage("https://b4x-4c17.kxcdn.com/images3/android.png", TrkImage1)
DownloadImage("https://b4x-4c17.kxcdn.com/images3/apple.png", TrkImage2)
DownloadImage("https://b4x-4c17.kxcdn.com/images3/hp.png", TrkImage3)
Dim p1 As B4XView = CreateItem((0xFFD00014), "First Image", TrkImage1, 360dip) ' TrkImage1,
clv1.Add(p1, expandable.CreateValue(p1, "1"))
Dim p2 As B4XView = CreateItem((0xFFFF7600), "Second Image", TrkImage2, 360dip) ' TrkImage2,
clv1.Add(p2, expandable.CreateValue(p2, "2"))
Dim p3 As B4XView = CreateItem((0xFFFFC600), "Third Image", TrkImage3, 360dip) ' TrkImage3,
clv1.Add(p3, expandable.CreateValue(p3, "3"))
End Sub
Sub CreateItem(clr As Int, Title As String, trkimg As ImageView, ExpandedHeight As Int) As B4XView 'trkimg As ImageView,
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, ExpandedHeight)
p.LoadLayout("Item")
p.SetLayoutAnimated(0, 0, 0, p.Width, p.GetView(0).Height) 'resize it to the collapsed height
lblTitle.Text = Title
pnlTitle.Color = clr
pnlExpanded.Color = ShadeColor(clr)
'ImageView2.Bitmap = trkimg
'DownloadImage(TrkImage1, trkimg)
Return p
End Sub
Sub DownloadImage(Link As String, TrkImage As ImageView )
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("Current link: " & Link)
'Log(j.GetString)
'TrkImage1.Bitmap = j.GetBitmap
'TrkImage1.Tag = j.GetBitmap
'j.GetBitmap = TrkImage
End If
j.Release
End Sub
Sub ShadeColor(clr As Int) As Int
Dim argb() As Int = GetARGB(clr)
Dim factor As Float = 0.75
Return xui.Color_RGB(argb(1) * factor, argb(2) * factor, argb(3) * factor)
End Sub
Sub GetARGB(Color As Int) As Int()
Private res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
res(3) = Bit.And(Color, 0xff)
Return res
End Sub
Sub clv1_ItemClick (Index As Int, Value As Object)
expandable.ToggleItem(Index)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub