Error during Inputlist

pieterfa

New Member
Licensed User
Longtime User
Pressing the hardware 'Back-button' when an inputlist is active results in an error message (ArrayIndexOutOfBoundsException).
This is understandable, but how to prevent this error message.
Activity_Keypressed('Back-button') is not working when an inputlist is active.
Is there a solution in this case??
thanks, Pieter from The Netherlands
 

pieterfa

New Member
Licensed User
Longtime User
Code itself is not so interesting. The error-message is generated in line: "Result = InputList (lst, "Maak keuze", iDummy)".
If I enter the 'back-button' on my samsung galaxy s2 when Inputlist is active then error message is shown and the application has to be ended.
Attached a screendump of the error message.

Thanks for your willingness to help me.
Pieter

QUOTE
Sub btnSelect_Click
Dim Result, iDummy As Int
Dim lst() As String
Dim Result As Int

lst = Array As String("Vandaag", "Week", "t/m Vandaag", "Alles", "Categorie/Boeking", "Budget")
iDummy = -1
For Teller = 0 To 5
If lst(Teller) = SelektieKode Then iDummy = Teller
Next
Result = InputList (lst, "Maak keuze", iDummy)
SelektieKode = lst(Result)

If SelektieKode = "Categorie/Boeking" Then
lst = Array As String("Alles", "Kasopname", "Logies", "Verblijf", "Brandstof", "Vervoer", "Leven", "Overig", _
"Kadootjes", "Wisselen", "Uitjes", "Buiten Budget", "Onvoorzien", "Privé Lia", "Privé Pieter", "Borg", "Giro")
Result = InputList (lst, "CATEGORIE - Selecteer", 0)
SelectedCategorie = lst(Result)
lst = Array As String("Alles", "Kas", "Giro", "On Hold", "Master Card", "Giro Pieter", "Giro Lia", "B-Leven", _
"B-Logies", "B-Verblijf", "B-Vakantie", "B-Transport", "B-Privé Lia", "B-Privé Pieter", "Startkas")
Result = InputList (lst, "BOEKING - Selecteer", 0)
SelectedBoeking = lst(Result)
End If

Gecancelled = False
Activity_Resume
End Sub
UNQUOTE
 

Attachments

  • SC20110922-174441.jpg
    SC20110922-174441.jpg
    11.9 KB · Views: 396
Upvote 0

Djembefola

Active Member
Licensed User
Longtime User
the error should not happen in the first but in the second line:

B4X:
Result = InputList (lst, "BOEKING - Selecteer", 0)
SelectedBoeking = lst(Result)

Why don't you check Result for negative values?

B4X:
Result = InputList (lst, "BOEKING - Selecteer", 0)
if Result < 0 then
  ...'cancelled by user
Else
  SelectedBoeking = lst(Result)
End if
 
Upvote 0

pieterfa

New Member
Licensed User
Longtime User
Thanks for the good advise. The advise solved my problem.
It proves that I am a real (but enthusiastic) amateur.
I am sure that after 2 or 3 years (I am 70 then), I have built enough knowledge to be able to help others.
Thanks, case closed
 
Upvote 0

nemethv

Member
Licensed User
Longtime User
Edit. Sorted...
Question was if this works w SQL or not.
This works:

B4X:
   DrinksInDataBaseCount = SQL1.ExecQuerySingleResult("SELECT count(DISTINCT DrinkName) FROM drinkslist")
   Cursor = SQL1.ExecQuery("SELECT DISTINCT DrinkName FROM drinkslist ORDER BY DrinkName")
   
   
   Dim DrinksListArray (DrinksInDataBaseCount) As String
       For i=0 To DrinksInDataBaseCount-1
       Cursor.Position = i
           DrinksListArray(i)=Cursor.getstring2(0)
       Next
   
      
   InputList(DrinksListArray,"Title", -1)
 
Last edited:
Upvote 0
Top