Android Question Problem with Preferences Builder

JMB

Active Member
Licensed User
Longtime User
Hi there,

Got a problem with using the PreferencesDialog.

I have been trying to build a form that allows for quick entry of Wind Direction and Wind Speed.

I got something up and running using two Number fields which worked fine, created using the B4J Forms Builder.

After some advice from Erel, I decided to try and use the Numeric Range entry.

I created a new JSON file using the B4J Forms Builder, loaded into my code, and I get this error now when the dialog is presented:

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 122 (B4XPlusMinus)
java.lang.NumberFormatException: empty String
   at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1071)
   at java.lang.Double.parseDouble(Double.java:547)
   at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:667)
   at b4a.example.b4xplusminus._setselectedvalue(b4xplusminus.java:652)
   at b4a.example.preferencesdialog._filldata(preferencesdialog.java:2540)
   at b4a.example.preferencesdialog$ResumableSub_ShowDialog.resume(preferencesdialog.java:590)
   at b4a.example.preferencesdialog._showdialog(preferencesdialog.java:408)

The code presenting the sub is shown below - Line 122 is the Wait For (WindDialog) call.

B4X:
Sub GetWind As ResumableSub
   
   Dim ReturnedWind As Wind
   WindDialog.Title = "Enter the Wind"
   
   ' Clear out the previous values
   WindSettings.Put("WindDirection","")
   WindSettings.Put("WindSpeed","")
   
   Wait For (WindDialog.ShowDialog(WindSettings, "OK", "CANCEL")) Complete (Result As Int)
   
   If Result = xui.DialogResponse_Positive Then
       
       ReturnedWind.Direction = WindSettings.Get("WindDirection")
       ReturnedWind.Speed = WindSettings.Get("WindSpeed")
       
       Return ReturnedWind
   Else
       Return Null
   End If
   
End Sub

Looking at the Preferences Dialog Demo, I can't see anything special about using a number with a range in terms of the code calling the Dialog - both use a map to return the values.

Am I missing something here?

Thanks for any help.

JMB
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Have you set the Start, End and Interval values:

java_dQr6xbNmUw.png
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
Hi Erel,

Yes, I set the ranges. I think I will try and rebuild a new layout JSON file and see if that works.

Thank you.

JMB
 
Upvote 0
Top