Sub EditTextSearch_TextChanged (Old As String, New As String)
If s.Len(s.Trim(New)) < 1 Then
ListViewSearch.Clear
Return
End If
holdp = pointer.Position
thm = pointer.RowCount - 1
Dim LVlbl As Label
LVlbl = ListViewSearch.SingleLineLayout.Label
LVlbl.Color = Colors.Gray
ListViewSearch.Clear
If RBnames.Checked Then
For l = 0 To thm
pointer.Position = l
seekvar = pointer.GetString ("name")
If s.At(s.Upper(seekvar), s.Upper(New)) > -1 Then
ListViewSearch.AddSingleLine(seekvar)
ListViewSearch.Invalidate
DoEvents
End If
Next
End If
If RBnotes.Checked Then
For l = 0 To thm
pointer.Position = l
seekvar = pointer.GetString ("enotesee")
If s.At(s.Upper(seekvar), s.Upper(New)) > -1 Then
ListViewSearch.AddSingleLine(pointer.GetString ("name"))
ListViewSearch.Invalidate
DoEvents
End If
Next
End If
pointer.Position = holdp
End Sub
This is code I use to search through an SQL data file and fill the ListView. I use it in the TextChanged event of the EditTextSearch field.
B4X:Sub EditTextSearch_TextChanged (Old As String, New As String) If s.Len(s.Trim(New)) < 1 Then ListViewSearch.Clear Return End If holdp = pointer.Position thm = pointer.RowCount - 1 Dim LVlbl As Label LVlbl = ListViewSearch.SingleLineLayout.Label LVlbl.Color = Colors.Gray ListViewSearch.Clear If RBnames.Checked Then For l = 0 To thm pointer.Position = l seekvar = pointer.GetString ("name") If s.At(s.Upper(seekvar), s.Upper(New)) > -1 Then ListViewSearch.AddSingleLine(seekvar) ListViewSearch.Invalidate DoEvents End If Next End If If RBnotes.Checked Then For l = 0 To thm pointer.Position = l seekvar = pointer.GetString ("enotesee") If s.At(s.Upper(seekvar), s.Upper(New)) > -1 Then ListViewSearch.AddSingleLine(pointer.GetString ("name")) ListViewSearch.Invalidate DoEvents End If Next End If pointer.Position = holdp End Sub
Margret, I usually prefer to query the db instead of looping through contents, and then populate the results. But I don't know if this is really faster. Just a thought![]()
Dim LVlbl As Label
LVlbl = ListViewSearch.SingleLineLayout.Label
LVlbl.Color = Colors.Gray
ListViewSearch.Clear
If RBnames.Checked Then
For l = 0 To thm
pointer.Position = l
seekvar = pointer.GetString ("name")
If s.At(s.Upper(seekvar), s.Upper(New)) > -1 Then
ListViewSearch.AddSingleLine(seekvar)
ListViewSearch.Invalidate
DoEvents
End If
Next
End If
He is asking about the categories in the list. I.e. the headers a,b,c,d...
Sent from my GT-I9000 using Tapatalk 2
Here's an example I've just made, you can find it attached.
On mine I used two listview. One with A-Z on the righthand side. Then I populate the main listview with all entries. Then if the user selects from the righthand list any letter a-z, it clears the left list and reloads it with items that start with the selected letter. Seems to work good with what I tested up to around 800 entries. See attached image.
I need to use a Dialog Search Box to find items in my listview. Somethink like this:
![]()
Any idea about how to do this?
On mine I used two listview. One with A-Z on the righthand side. Then I populate the main listview with all entries. Then if the user selects from the righthand list any letter a-z, it clears the left list and reloads it with items that start with the selected letter. Seems to work good with what I tested up to around 800 entries. See attached image.
ListView.SetSelection