Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private button_width As Float
Private HSV_TOP_BAR As HorizontalScrollView
Private button1 As ImageView ' Not created with the Designer
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")
Activity.LoadLayout("mainLayout")
button1.Initialize("button1")
button1.Color=Colors.ARGB(255,0,255,0) 'worked well
button_width=HSV_TOP_BAR.Height
Log(button_width)
HSV_TOP_BAR.Panel.AddView(button1,0,0,button_width,button_width)
Dim bmp As Bitmap=LoadBitmap(File.DirAssets,"move_left.png")
Log(bmp)
Dim r1,r2 As Rect
r1.Initialize(0,0,bmp.Width,bmp.Height)
r2.Initialize(0,0,button_width,button_width)
Dim c As Canvas
c.Initialize(button1)
c.DrawBitmap(bmp,r1,r2) '<-- HaHa , OK !
'Causes: When ImageView is created with code dynamically, assigns to its Bitmap property not work.
'button1.Bitmap=bmp'LoadBitmapSample(File.DirAssets,"move_left.png",128,128) '<-- not work!
'button1.Bitmap=LoadBitmap(File.DirAssets,"move_left.png") '<-- not work!
'bmp=LoadBitmap(File.DirAssets,"move_left.png")
'Log(bmp) 'Load success.
'button1.SetBackgroundImage(bmp) '<-- not work
'ImageView1.Bitmap=bmp
'HSV_TOP_BAR.Panel.AddView(ImageView1,130,0,100%x/5,100%y)
End Sub