Android Question Something is wrong with InputMapAsync or map

Scantech

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Button1_Click
'    Dim WhatSentence As String = "Please test This sentence As to Why it Is missing Words in the InputMapAsync"
    Dim WhatSentence As String = "The record of the genealogy of Jesus the Messiah the son of David the son of Abraham"
    
    'the and of words are not included with the second WhatSentence!!!! why???
    
    Dim sa1() As String
    sa1 = Regex.Split(" ", WhatSentence)
    
    Dim rlst As List
    rlst.Initialize
    
    For Each s1 As String In sa1
        rlst.Add(s1.Trim)
    Next

    'Store it in the Map
    Dim m As Map
    m.Initialize
        
    For x = 0 To rlst.Size -1
        Log(rlst.Get(x))
        m.Put(rlst.Get(x), False)
    Next
                
    'Show the list
    InputMapAsync(m, "Select the words", False)
    Wait For InputMap_Result
End Sub

I can't figure out what i am doing wrong. The second WhatSentence has missing words in InpuMapAsync, but the first one is ok. They are all separated with space, regex and added to the map.
 

OliverA

Expert
Licensed User
Longtime User
Which words are missing? Duplicate ones (like the, son, of)? That would be normal for a map. Or is it something else?
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
Yeah you are right. I confused myself with map function. Is there a workaround for my function?
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
Use B4XListTemplate + B4XDialog.
This is not possible. I tried it and looks like map is involved with ListTemplate.SelectedItems. I selected all the words and the duplicates will not be shown in ListTemplate.SelectedItems. I can understand the list should not have duplicates. But it will be nice to allow it.

I guess im going with your second option. I need to research how to use BCTextEngine .


'Part of my codes (the lWords contains the WhatSentences from the above and are seperated into 17 word list items.
B4X:
    Dim ListTemplate As B4XListTemplate
    ListTemplate.Initialize
    ListTemplate.MultiSelectionMinimum = 1
    ListTemplate.Options = lWords
    ListTemplate.AllowMultiSelection = True

    Wait For (Dialog.ShowTemplate(ListTemplate, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        Dialog.Show($"You selected: ${ListTemplate.SelectedItems}"$, "OK", "", "")

The idea of the project is allow multiple words be selected and translated through the web. I guess i have to go with single click word to translate with BCTextEngine or I might consider customlistview with checkbox. That should work.
 
Last edited:
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
1.jpg

I did it with customlistview! I think it is more flexible with select all option. Thanks
 
Upvote 0
Top