Hi all,
i am struggling with the idea to iterate through BitmapDrawables like you can see on the code snippet. As i did read the tutorials for generating Buttons with a "for next" loop, i'd like to do the same with attaching png's to the Buttons.
Any idea?
My solution causes an error "inconvertible" types (of course Drawable vs. string), but there must be a way around.....
:BangHead:
i am struggling with the idea to iterate through BitmapDrawables like you can see on the code snippet. As i did read the tutorials for generating Buttons with a "for next" loop, i'd like to do the same with attaching png's to the Buttons.
Any idea?
My solution causes an error "inconvertible" types (of course Drawable vs. string), but there must be a way around.....
:BangHead:
B4X:
Dim bmp0, bmp1, bmp2, bmp3 As BitmapDrawable
bmp0.Initialize(LoadBitmap(File.DirAssets, "ic_menu_today.png"))
bmp1.Initialize(LoadBitmap(File.DirAssets, "ic_menu_week.png"))
bmp2.Initialize(LoadBitmap(File.DirAssets, "ic_menu_favorite.png"))
bmp3.Initialize(LoadBitmap(File.DirAssets, "ic_menu_settings_holo_light.png"))
'Add menu items to menu
For i = 0 To 3 'create 4 buttons as panels
Log(i)
Dim mBtn As Panel
mBtn.Initialize("mBtn")
mBtn.Color = Colors.Black
If i = 0 Then
pnlMenu.AddView(mBtn,0, 2dip, mBtnWidth, mHeight-3dip)
mBtn.Background = "bmp" & i
Else
pnlMenu.AddView(mBtn,1dip + mBtnWidth * i, 2dip, mBtnWidth-1dip, mHeight-3dip)
mBtn.Background = "bmp" & i
End If
Next