Hi. (I repost here same question posted as reply to original SpotLight post)
I am thinking to use this nice feature for displaying some country flags and doing the relative choice.
I just copied the code from Ilan example.
The difference is that I haven't put the button on a panel, but directly on activity. (In my code the "btn" button is named "Lingua").
My code is hereunder, followed by the log with the error. The program, anyway, works.
Any hint? Thanks in advance.
LOG:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 32 (Starter) <<<<<<<<<<<<<<<<<< ???? <<<<<<<<<<<<<
java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference
at anywheresoftware.b4a.objects.ViewWrapper.getWidth(ViewWrapper.java:140)
at b4a.example.spotlight._show(spotlight.java:509)
at b4a.OpenMuseum.main._lingua_click(main.java:421)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:5714)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22589)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Pause, UserClosed = true **
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
I am thinking to use this nice feature for displaying some country flags and doing the relative choice.
I just copied the code from Ilan example.
The difference is that I haven't put the button on a panel, but directly on activity. (In my code the "btn" button is named "Lingua").
My code is hereunder, followed by the log with the error. The program, anyway, works.
Any hint? Thanks in advance.
B4X:
Sub Globals
Private splight As SpotLight
Private Lingua AsButton
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
'Create Spotlight Menu
Dim Italia,England,Russia AsBitmap' used always same jpg for the flags, just experiment
Italia.Initialize(File.DirAssets,"italia.jpg")
England.Initialize(File.DirAssets,"italia.jpg")
Russia.Initialize(File.DirAssets,"italia.jpg")
splight.Initialize(Me,"splight",10%y,False,False,True,Lingua,Activity)
splight.additem("Italia", Colors.Black,18,Italia)
splight.additem("England",Colors.Black,18,England)
splight.additem("Russia", Colors.Black,18,Russia)End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Lingua_Click
splight.show
End Sub
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 32 (Starter) <<<<<<<<<<<<<<<<<< ???? <<<<<<<<<<<<<
java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference
at anywheresoftware.b4a.objects.ViewWrapper.getWidth(ViewWrapper.java:140)
at b4a.example.spotlight._show(spotlight.java:509)
at b4a.OpenMuseum.main._lingua_click(main.java:421)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:5714)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22589)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Pause, UserClosed = true **
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **