Android Question MiniSearchView AutoComplete with Database

james_sgp

Active Member
Licensed User
Longtime User
Is it possible, has anyone made this work by looking up data in a database table rather than using a text file? As I'd like to use it to autocomplete a form, that has its records in a db table.


Thanks.
 

james_sgp

Active Member
Licensed User
Longtime User
Hi, i tried that using DButils Memorytable (loading it into a list), but MiniShearchView is not getting those items... its giving me [Ljava.lang.String;@21c6cca0 instead of a list of names?
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
    
    File.Copy(File.DirAssets,staffDB,File.DirInternal,staffDB)
    sql_staff.Initialize(File.Dirinternal, staffDB, False)
    
    Dim m As List

    m = DBUtils.ExecuteMemoryTable(sql_staff, "SELECT name FROM staff;", Null,0)
    If m = Null Or m.IsInitialized = False Then 'Null will return if there is no match
    Else
        If m.Size = 1 Then
        End If
    End If   
     Currencies.SetItems(m)

End Sub
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
DButils returns a List (M in my code), as the 'setitems' asked for a list I assumed I could give it the list 'm'.
I don`t really get what you mean that the list must be structured like the file?
The MiniSearchView module expecting SetItems(Items As List) As Object"
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Ok, I got it to work; I read the memorytable list M into another list and passed that t MiniSearchView.

Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The Searchview needs a List of SINGLE ITEMS. One String per item.

- ExecuteMemoryTable: Executes a SELECT query and reads all the records into a list. Each item in the list is an array of strings that represents a record in the result set.

Fazit: ExecuteMemoryTable is the WRONG Solution as it is not a Solution for your Problem.
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Ok, yep a much simpler solution is to use DButil.executelist...
So filling the list is working, I can type a name and everything is good.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…