This example shows how to filter the contents of a database and load the results in a listview using an edittext. for each letter entered in edittext the results are shown in the listview. It could be useful for someone.
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
Dim ListRow(1000) As String
dim Cursor1 As Cursor
ListView1.Clear
Cursor1=s.ExecQuery("SELECT Col1 FROM Table1 WHERE Col1 LIKE('" & "%" & "')")
If Cursor1.RowCount > 0 Then
For i= 0 To Cursor1.RowCount-1
Cursor1.Position =i
ListRow(Cursor1.Position) = Cursor1.GetString("Col1")
If ListRow.Contains(EditText1.Text) then
ListView1.AddSingleLine(ListRow(i))
EndIf
Next
Cursor1.Close
End If
EndSub
Last edited: