I am using a simple menu using the following code, but sometimes the Menu seems to flicker (perhaps if I hold the "click" a little too long?) and the response becomes -3.
So the first problem is How does that happen? -3 is not a choice as far as I know.
I then tried to work around it by adding a loop to tell the user to select again, the final code is shown below:
After I ran into this problem I tried putting the menu into a loop, so if the -3 was returned the user would be asked to re-input a response. This leads to the menu freezing and the following log:
Has anyone run into a problem like this with the menu? Would appreciate some help.
So the first problem is How does that happen? -3 is not a choice as far as I know.
I then tried to work around it by adding a loop to tell the user to select again, the final code is shown below:
B4X:
Dim lstNPMenu As List
Dim lMenuChoice As Long
' For the menu loop to start
lMenuChoice = -1
' Set up the menu selections
lstNPMenu.Add("Cancel")
lstNPMenu.Add("Play Now")
lstNPMenu.Add("Set TrackStop " & TMM.iif(TrackRecord.TrackStop, "Off", "On"))
lstNPMenu.Add("Move")
lstNPMenu.Add("Move to Start of Queue")
lstNPMenu.Add("Move to End of Queue")
lstNPMenu.Add("Remove from Queue")
' Menu loop:
Do While Not("0123456".Contains(lMenuChoice))
' Open dialogue to choose an action
lMenuChoice = InputList(lstNPMenu,"Options",0)
' Respond to chosen selection
Select lMenuChoice
Case 0
' Cancel
Case 1
Code
Case 2
Code
Case 3
Code
Case 4
Code
Case 5
Code
Case 6
Code
Case Else
ToastMessageShow("System Returned an Invalid Entry" & CRLF & "Please Choose Again.",False)
End If
End Select
Loop
After I ran into this problem I tried putting the menu into a loop, so if the -3 was returned the user would be asked to re-input a response. This leads to the menu freezing and the following log:
B4X:
java.lang.NullPointerException
at anywheresoftware.b4a.Msgbox$DialogResponse.onClick(Msgbox.java:118)
at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:934)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3067)
at android.widget.AbsListView$1.run(AbsListView.java:3968)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Has anyone run into a problem like this with the menu? Would appreciate some help.
Last edited: