Imageview problem cannot set left&top

lorebf

Member
Licensed User
Longtime User
I'm trying to create my own imageviews, but it generates errors when trying to set the top/left/width/height.

Here is my code:

Code:
Sub Globals
   Dim spr(128) As ImageView
   Dim sheet As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
   sheet.Initialize(File.DirAssets, "smb.png")   'ladda in bilden
   spr(0).Initialize("spr")
   spr(0).Enabled=True
   spr(0).Visible=True 
   spr(0).Bitmap=sheet
   spr(0).Gravity=Gravity.FILL
   spr(0).SetLayout(0,0,32,32)
End Sub

The line with "setlayout" is the line that generates the error "java.lang.nullpointerexeption"
 
You need to add spr(0) to the Activity (with Activity.AddView) first before trying out SetLayout
 
Upvote 0
You need to add spr(0) to the Activity (with Activity.AddView) first before trying out SetLayout

Thank you, it worked :)

Is there a way to make
spr(0).Bitmap=sheet
to only take a small part of the sheet bitmap? for instance 0,0 to 32,32?
 
Upvote 0
Back
Top