Scrolling canvas in panel

Ramirez

Member
Licensed User
Longtime User
Hello

I try this code adapted from a Klaus post

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   ' nécessaire pour dessiner la courbe
   Dim tableau As Canvas
   Dim courbe As Path
   Dim Panneau As Panel
   Dim Image As Bitmap
   
   'objects graphiques
   Dim lblDate As Label

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("formHistory")
   
   ' Affichage de la date du jour
   '------------------------------
   DateTime.DateFormat = "dd/MM/yyyy"
   lblDate.Text=DateTime.Date(DateTime.Now)
   
   ' Création de la zone de dessin
   '-------------------------------
   Panneau.Width = 300
   Panneau.Left = 0
   Panneau.Top = 360
   Panneau.Height = 140
   
   tableau.Initialize(Panneau)
   Image.Initialize3(tableau.Bitmap)


End Sub


I don't understand what is the difference between my code and the Klaus code, but mine give me an error : "Object should be first initialized (panel)"

Any idea of my mistake ?
 

Ramirez

Member
Licensed User
Longtime User
In this case, "Missing parameters" because it's necessary to specify a taget.
If I specify

B4X:
Panneau.Initialize(Activity)

I have a failure: Java.lang.NullPointerException


:( :( :( :(
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm afraid that you don't have a Panel with the name 'Panneau' in your formHistory layout.

Initialize is needed if you add views by code but you must also add this view to a parent view.
Initialize is not needed when the view is defined in the layout file.

You should use this code if you want to use event from the panel:
B4X:
Panneau.Initialize("Panneau")
Activity.AddView(Panneau, 0, 360, 300, 140)
And you could use this code if you don't want to use event from the panel:
B4X:
Panneau.Initialize("")
Activity.AddView(Panneau, 0, 360, 300, 140)
To be able to give you a concrete answer we need to have your whole project as a zip file (IDE menu File/Export As zip.

Best regards.
 
Upvote 0

Ramirez

Member
Licensed User
Longtime User
RHAAAAA I love you Klauss :sign0100:

You're right, I don't create panel on my layout ! :BangHead:

I understand my mistake thanks a lot.
 
Upvote 0
Top