Android Question Problem with ListView on Different Devices

stingrae

Member
Licensed User
Longtime User
Hi,

I'm wondering if anyone can help.

I have a ListView control which works perfectly on one device, but doesn't on the other. There are two main issues, and I think they're related.

Firstly, I have this code:

B4X:
    lstClasses.Clear
    lstClasses.SingleLineLayout.Label.TextSize = 20
    lstClasses.SingleLineLayout.Label.Gravity = Gravity.CENTER
   
    lstClasses.SetVisibleAnimated(900 , True)
   
    Dim CDPressed,CDNormal As ColorDrawable
    CDPressed.Initialize(Colors.Blue,0)  ' Normal color
    CDNormal.Initialize(Colors.Blue,0) 'Selected color

This works fine on one device and sets the colour of the selected row to Blue. But on the other, it just quickly flashes blue and goes back to how it looked before being clicked.

And then the main error is when I run this:
B4X:
Sub lstClasses_ItemClick (Position As Int, Value As Object)
    intClassSelectionID = Position
    lstClasses.SetSelection(Position)
End Sub

Sub btnCheckInOk_Click
    Dim intClassID As Int = lstClasses.GetItem(intClassSelectionID)
    ' rest of code here

On the first device, the Global Variable intClassSelectionID is set ok, and then the ClassID is set from that.
On the second, intClassSelectionID is saved ok, but then when the button is clicked, it still has the same value as the first device, only it crashes with the following error.

I'm confused why it's working on one but not the other. In fact it works on most machines. I've only just aquired a new tablet to figure out it crashes on some.

Thanks in advance.

ps. here is the error text from btnCheckInOk_Click:
Error occurred on line: 740 (Main)
java.lang.NumberFormatException: Invalid double: "false"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:94)
at java.lang.StringToReal.parseDouble(StringToReal.java:263)
at java.lang.Double.parseDouble(Double.java:295)
at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:646)
at b4a.example.main._btncheckinok_click(main.java:647)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
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:80)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…