How1 to access the imageview that is inside a panel

rclatorre

Member
Licensed User
Longtime User
Hi all,

I have created an array of panels within which an image will go (Create panel and put an ImageView by code).

I'm using HttpJob to bring the image to be in each of the panels (I added an attribute to control HttpJob Index in position).

The query is: how do I assign the image to the corresponding panel when running the JobDone?, Considering that I have the corresponding index to access array panels.

This is the code:

'Activity module
Sub Process_Globals
'We put this information to the panel of the panel tag for the pages
Type PanelInfo (Index As Int, LayoutLoaded As Boolean)
End Sub

Sub Globals
'These variables can only be accessed From this module.
Dim panels (5) As Panel

'The container and the objects ViewPager
Dim container As AHPageContainer
Dim pager As AHViewPager

End Sub
-------------------------------------------------- -----------------
Sub Activity_Create (FirstTime As Boolean)

'Initialize the panels we use for the pages and put them in the container
container.Initialize

For i = 0 To 4

As job1 Dim HttpJob
job1.Initialize ("job3", Me)
job1.Index = i
job1.Download ("http://www.b4x.com/forum/images/categories/android.png")

panels (i). Initialize ("panel")
panels (i) = CreatePanel (i)
container.AddPage (panels (i), "Page" & i)[/INDENT]

Next

'Now we have a container with our panels just add it to the pager object
pager.Initialize (container, "Pager")

'Now we can add the pager to the activity
Activity.AddView (pager, 0, 35dip + 2dip, Activity.Width, Activity.Height-48dip-35dip-2dip)

End Sub

Sub CreatePanel (index As Int) As Panel
Dim pan As Panel
Dim pi As PanelInfo
pi.Initialize ()
pi.index = index
pi.LayoutLoaded = False
pan.Initialize ("panel")
Colors.RGB pan.Color = (Rnd (0, 150), Rnd (0,150), Rnd (0.150))
Dim img As ImageView
img.Initialize ("")
img.Gravity = Gravity.CENTER
pan.AddView (img, 0, 0, 100% x 100%)
pan.Tag = pi
Return pan
End Sub

-------------------------------------------------- -----------------
Sub JobDone (Job As HttpJob)
Log ("JobName =" & Job.JobName & "Success =" & Job.Success)
If Job.Success = True Then

----- >>>??????????

Else
Log ("Error:" & Job.ErrorMessage)
ToastMessageShow ("Error:" & Job.ErrorMessage, True)
End If
Job.Release
End Sub

Thanks
 

rclatorre

Member
Licensed User
Longtime User
Thanks to all,

Solved the case:

Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then

panels(Job.Index).GetView(0).SetBackgroundImage(Job.GetBitmap)

Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
 
Upvote 0
Top