B4J Question SetImage function

Daestrum

Expert
Licensed User
Longtime User
simple example
B4X:
dim img as Image
dim imv as ImageView
...
 imv.Initialize("imv") ' set event name for imageview
 img.Initialize("C:/temp","yourimage.jpg") ' load the image
 imv.SetImage(img)  ' set the imageview to img
 
Upvote 0
Ok, thanks a lot, but I've made a simple program with an ImageView and two buttons. When I press a button, the ImageView should show me a certain image. But the ImageView remains unchanged.
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
  
    Dim imv As ImageView
    Dim cirese, pere As Image
  
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Ly1") 'Load the layout file.
    MainForm.Show
  
    imv.Initialize("imv")
    pere.Initialize("E:\_AndreiINFO\B4J\Projects\Memory\Files", "pere.png")
    cirese.Initialize("E:\_AndreiINFO\B4J\Projects\Memory\Files", "cirese.jpg")
  
    imv.SetImage(cirese)
  
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub b2_MouseClicked (EventData As MouseEvent)
    imv.GetImage(pere)
End Sub

Sub b1_MouseClicked (EventData As MouseEvent)
    imv.GetImage(cirese)
End Sub
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
You used GetImage in the MouseClicked events, it should be SetImage
 
Upvote 0
Top