Android Question Get NullPointerException with label tag

imgsimonebiliato

Well-Known Member
Licensed User
Hello,
I want to check the value of the tag property of a label, but I get this error message:


B4X:
If lb.Tag = bt.Text Then
java.lang.NullPointerException

    at it.android.imgspa.and_Cons.main._btmac_click(main.java:427)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66)
    at android.view.View.performClick(View.java:4209)
    at android.view.View$PerformClick.run(View.java:17431)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:153)
    at android.app.ActivityThread.main(ActivityThread.java:5297)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
 

NJDude

Expert
Licensed User
Try assigning the value of the tag to a string variable and then query the variable instead of the tag directly. like:
B4X:
Private myVar As String

myVar = lb.Tag

If myVar = bt.Text Then ...
 
Top