iOS Question B4I - refreshing icons into imageview

Zak Petr

Member
Licensed User
Hi,

I am creating list of menu items programatically with my function , like this:
B4X:
Sub add_menuitem(inp_ico As String , inp_text As String ,  inp_obj As Panel )
     
    Dim item_menu, x As  Panel
    Dim item_lbl_obj As Label
    Dim item_img As ImageView
   
    item_menu.Initialize("item_menu")
    item_menu.LoadLayout("item_menu")
    item_menu.Height    = inp_height
     
    
    x = item_menu.GetView(0)
     
    '======= icon
    item_img = x.GetView(0)
   AjustaImageView(item_img,File.DirAssets,inp_ico)
    
    
    '======= text
    item_lbl_obj = x.GetView(1)
    item_lbl_obj.Text =  inp_text
    
    inp_obj.AddView(item_menu, 0dip, inp_obj.height, inp_width ,inp_height)
     

    inp_obj.Height = inp_obj.Height + item_menu.Height

End Sub

B4X:
Sub AjustaImageView(Imv As ImageView, Dir As String, FileName As String)
    Private bmp As Bitmap = LoadBitmap(Dir, FileName)
    Dim Delta, Height, Width As Int
    If bmp.Width / bmp.Height > Imv.Width / Imv.Height Then
        Height = bmp.Height / bmp.Width * Imv.Width
        Delta = (Imv.Height - Height) / 2
        Imv.Height = Height
        Imv.Top = Imv.Top + Delta
    Else
        Width = bmp.Width / bmp.Height * Imv.Height
        Delta = (Imv.Width - Width) / 2
        Imv.Width = Width
        Imv.Left = Imv.Left + Delta
    End If
    Imv.Bitmap = bmp
End Sub


For each item I load layout which is created in designer.


Everythink work properly if I debug project step by step.

But the problem is , that this icons are not showed (rendered), if I run applicaton immediadly (without ste by step).

How to refresh imageview ?
 

Attachments

  • layout_item_menu_structure.png
    layout_item_menu_structure.png
    15.9 KB · Views: 189
Top