je declare comme ceci dans sub globals :
je l'initialise ici :
sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Timer1.Initialize("Timer1",1000)
Popup.Initialize(Activity)
Activity.LoadLayout("Layout1")
'Label1.Text=Popup.IsInitialized
Bin = False
End Sub
Là j'appelle la fonction :
Sub Moral_Click
'MsgboxAsync("Moral des Joueurs "&Jmoral&"%","")
'ToastMessageShow("Moral des Joueurs "&Jmoral&"%",False)
Popup.VerticalCenterPercentage = 50
Popup.Show("Moral des Joueurs "&Jmoral&"%")
End Sub
Et voilà les erreurs que j'ai au moment au le message doit s'afficher:
Logger connecté à : samsung SM-M127F
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
Error occurred on line: 39 (BCToast)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:91)
at anywheresoftware.b4a.objects.B4XViewWrapper.getWidth(B4XViewWrapper.java:144)
at b4a.example.bctoast$ResumableSub_Show.resume(bctoast.java:205)
at b4a.example.bctoast._show(bctoast.java:102)
at b4a.example.main._moral_click(main.java:1334)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7892)
at android.view.View.performClickInternal(View.java:7869)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:30891)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)