Hi to everybody
I have a list of strings and an EditText.
I would like that, as soon as the user writes something on the EdiText, a search is done on the list and, if any element of the List contains partially the entered text, this latter will be replaced by the List element.
The idea is explained in the attached project. Here we have an EditText and a Label. The Label changes, of course. The problem is to change the EditText, (for obvious reasons).
Thanks for any hint.
I have a list of strings and an EditText.
I would like that, as soon as the user writes something on the EdiText, a search is done on the list and, if any element of the List contains partially the entered text, this latter will be replaced by the List element.
The idea is explained in the attached project. Here we have an EditText and a Label. The Label changes, of course. The problem is to change the EditText, (for obvious reasons).
Thanks for any hint.
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Dim ListaPunti As List
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private EditText1 As EditText
Private Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ListaPunti.Initialize
ListaPunti.Add("1111")
ListaPunti.Add("2222")
ListaPunti.Add("3333")
ListaPunti.Add("4444")
ListaPunti.Add("5555")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub EditText1_TextChanged (Old As String, New As String)
Label1.Text=""
If ListaPunti.IsInitialized Then
For Each b As String In ListaPunti
If b.Contains(New) Then
Label1.Text=b
Exit
End If
Next
End If
End Sub