I'm having some trouble getting a bitmapdrawable loaded into an imageview.
Code which doesn't work
http://pastebin.com/ty7NubBp
Code which works
http://pastebin.com/Ja69wyCQ
What I'm trying to do is load the bitmap from the objects/res folder.
I can get the Bitmap to load without using an Imageview very easily with
Dim BitmapDrawable2 As BitmapDrawable
BitmapDrawable2 = AndroidResources2.GetApplicationDrawable("topicon")
Icon1.Bitmap = BitmapDrawable2.Bitmap
And even have managed to load it with designer. However this code just doesnt seem to want to work through any variations I've tried.
If you could point me in the direction for more information (i've tried search but im not entirely sure im searching the correct terms) I would be forever in your debt
Regards
Aaron
Code which doesn't work
http://pastebin.com/ty7NubBp
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim p As Panel
Dim androidresources1 As AndroidResources
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
p.Initialize("me")
Activity.AddView(p, 0dip,0dip, 100%x, 100%y)
p.Color = Colors.White
Dim iv As ImageView
Dim bd As BitmapDrawable
iv.Initialize("iv")
bd = androidresources1.GetAndroidDrawable("ic_action_email")
iv.Bitmap = bd.Bitmap
p.AddView(iv, 16dip, 12dip, 32dip, 32dip)
End Sub
Code which works
http://pastebin.com/Ja69wyCQ
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim p As Panel
Dim androidresources1 As AndroidResources
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
p.Initialize("me")
Activity.AddView(p, 0dip,0dip, 100%x, 100%y)
p.Color = Colors.White
Dim iv As ImageView
iv.Initialize("iv")
iv.Bitmap = LoadBitmap(File.DirAssets, "ic_action_email.png")
p.AddView(iv, 16dip, 12dip, 32dip, 32dip)
End Sub
What I'm trying to do is load the bitmap from the objects/res folder.
I can get the Bitmap to load without using an Imageview very easily with
Dim BitmapDrawable2 As BitmapDrawable
BitmapDrawable2 = AndroidResources2.GetApplicationDrawable("topicon")
Icon1.Bitmap = BitmapDrawable2.Bitmap
And even have managed to load it with designer. However this code just doesnt seem to want to work through any variations I've tried.
If you could point me in the direction for more information (i've tried search but im not entirely sure im searching the correct terms) I would be forever in your debt
Regards
Aaron