Android Question Why are my overflow menu items not working when I first run my app?

alexwekell

Member
Licensed User
Longtime User
OK, I've narrowed it down to this bit of code:

B4X:
'Builds the index and returns an object which you can store as a process global variable
'in order to avoid rebuilding the index when the device orientation changes.
Public Sub SetItems(Items As List) As Object
    Dim startTime As Long
    startTime = DateTime.Now
    ProgressDialogShow2("Building index...", False)
    Dim noDuplicates As Map
    noDuplicates.Initialize
    prefixList.Clear
    substringList.Clear
    Dim m As Map
    Dim li As List
    For i = 0 To Items.Size - 1
        If i Mod 100 = 0 Then DoEvents
        Dim item As String
        item = Items.Get(i)
        item = item.ToLowerCase
        noDuplicates.Clear
        For start = 0 To item.Length
            Dim count As Int
            count = MIN_LIMIT
            Do While count <= MAX_LIMIT AND start + count <= item.Length
                Dim str As String
                str = item.SubString2(start, start + count)
                If noDuplicates.ContainsKey(str) = False Then
                    noDuplicates.Put(str, "")
                    If start = 0 Then m = prefixList Else m = substringList
                    li = m.Get(str)
                    If li.IsInitialized = False Then
                        li.Initialize
                        m.Put(str, li)
                    End If
                    li.Add(Items.Get(i)) 'Preserve the original case
                End If
                count = count + 1
            Loop
        Next
    Next
    ProgressDialogHide
    Log("Index time: " & (DateTime.Now - startTime) & " ms (" & Items.Size & " Items)")
    Return Array As Object(prefixList, substringList)
End Sub

When this is removed my overflow menu items work fine.

In my read only text file (cities.txt) it successfully returns an array of [a,b,c], but still, menu items stop

Edit: I've commented out these two lines and all seems to work:

B4X:
    prefixList.Clear
    substringList.Clear

Edit2: I lied, it's still broken...
 
Last edited:
Upvote 0

alexwekell

Member
Licensed User
Longtime User
Alright, so I have narrowed it down to something, again. It has to do with the code above and this text file.

Edit: Initializing my searchview before all of my other code seems to have fixed the issue
 

Attachments

  • cities.txt
    1.4 KB · Views: 186
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…