Sub ShowImage (data As String)
Msgbox (data,"") ' Displays the data in a message box (show_green)
Log(data) ' writes show_green
Dim MyImage As ImageView
MyImage.Initialize (MyImage) ' also tried the Activity Page Name (Main)
If data = "show_green" Then
Log("set Image to Green")
MyImage.Bitmap = LoadBitmap(File.DirAssets,"green.png")
End If
End Sub
Activity Module:
Activity Name = Main
B4X:
Sub Globals
Dim MyImage As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("MainGUI") ' This has just 1 ImageView on it called MyImage, and I have added the image called green.png in there as well
code1.ShowImage("show_green") ' change the image from the code1 module
End Sub
I have also added the image in the 'Files' from the right side bar in the IDE.
However, the image does not display but it does write 'set Image to Green' in the Log, so I know it is going to that part of the code.
Sub ShowImage (imv As ImageView, data As String)
Msgbox (data,"") ' Displays the data in a message box (show_green)
Log(data) ' writes show_green
If data = "show_green" Then
Log("set Image to Green")
imv.Bitmap = LoadBitmap(File.DirAssets,"green.png")
End If
End Sub
and in Main this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("MainGUI") ' This has just 1 ImageView on it called MyImage, and I have added the image called green.png in there as well
code1.ShowImage(MyImage, "show_green") ' change the image from the code1 module
End Sub