Android Question change text color of a simple label causes crash

ermiakhan

Member
change text color of a simple label causes crash
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.LabelWrapper.setTextColor(int)' on a null object reference

for this line
lbl_bing_text.TextColor=Colors.Black
 

DonManfred

Expert
Licensed User
Longtime User
Please upload a small project which shows the issue.

Use File->Export as Zip in the Ide to export it. Upload this zip
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Looking at the exception...
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.LabelWrapper.setTextColor(int)' on a null object reference
...I read the message as "Tried to do stuff on something that wasn't there"

And then applying that to your code...
lbl_bing_text.TextColor=Colors.Black
...I read the code as "Try to set the text color on lbl_bing_text"

Combine these, and I imagine that lbl_bing_text simply isn't a valid reference to a label at that point in your code. Set a breakpoint and inspect it, and it will probably show as null.
 
Upvote 0
Top