Blank images in a scrollview???

Mark Read

Well-Known Member
Licensed User
Longtime User
As i mentioned in a previous post, I have modified the FlickrViewer example to read a webpage and download the thumbnail pictures. The pictures are added as a BitmapDrawable to an ImageView. The ImageView is then added to a scrollview.

So far so good.

The code works but I have 2 annoying problems.

1. For each added thumbnail, it would appear that a blank space (as big as the thumbnail) is added at the top of the scrollbar! Not a big prolem for a few thumbs but there are 290!

2. My loop to add the thumbnails seems to work for up to 4 images and then for 5 or more it hangs. Should I add a pause between downloading?

Here is the code used to fill the scrollview. The rest of the code is as per FlickrViewer

B4X:
Sub ImagesJobDone (Job As HttpJob)
   'Log("ImageJobDone called "&ImageIndex)
   If Job.Success = True Then
      Dim iv As ImageView
      iv.Initialize("") 'not interested in any events so we pass empty string.
      Dim bd As BitmapDrawable
       bd.Initialize(Job.GetBitmap)
       iv.Background = bd 'set the background of the image view.
      iv.Gravity=Gravity.fill
      iv.Tag=ImageIndex
      
'      If iv.Height>190 Then
'         iv.Width=iv.Width*190/iv.Height
'         iv.Height=190
'         End If
         
      
       'add the image view to the scroll bar internal panel. Left, Top, Width, Height
         ScrollView1.Panel.AddView( iv, 5dip, 5dip + (ImageIndex * 200dip), iv.Width, 190dip)
      
      'ivs(ImageIndex).Bitmap = Job.GetBitmap
      'ivs(ImageIndex).Gravity = Gravity.FILL
   End If
   ImageIndex = ImageIndex + 1
   ScrollView1.Panel.Height=ImageIndex * 200dip
End Sub
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Thanks for the info Erel but that didn't help. I've posted the whole code. The blanks seem to come from the wrong value of ImageIndex

Problem solved.

Have to learn to go away and come back later.

ImageIndex counter not reset in another sub. Blind as a bat again!! :signOops:
 
Last edited:
Upvote 0

Similar Threads

Top