Hello everyone,
this is my first post after a little time working with b4a and surfing the forums. I would like to thanks everyone in advance for all the help given in the forum and say that this is a great community. After that, going straight to the issue.
I would like to know if it is possible to control the text changes on the SearchField within a B4XSearchTemplate. I am trying to get the SearchField within the B4XSearchTemplate object and setting a TextChanged event (sub) for it. I am pretty sure that I am doing something wrong, since it does not call the event sub.
I don't understand how to set events programatically so if someone could point me to the right documentation or tutorials I'd really appreciate it.
This is my code, I highlihted the lines that should (in my head) do the work. Also I attached the whole project, in case someone wants to try and correct it.
Thanks so much
this is my first post after a little time working with b4a and surfing the forums. I would like to thanks everyone in advance for all the help given in the forum and say that this is a great community. After that, going straight to the issue.
I would like to know if it is possible to control the text changes on the SearchField within a B4XSearchTemplate. I am trying to get the SearchField within the B4XSearchTemplate object and setting a TextChanged event (sub) for it. I am pretty sure that I am doing something wrong, since it does not call the event sub.
I don't understand how to set events programatically so if someone could point me to the right documentation or tutorials I'd really appreciate it.
This is my code, I highlihted the lines that should (in my head) do the work. Also I attached the whole project, in case someone wants to try and correct it.
textoBuscar:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Dialog As B4XDialog
Private XUI As XUI
Private btnSearch As SwiftButton
Private SearchTemplate As B4XSearchTemplate
Private Base As B4XView
Private textoBuscar As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
Base = Activity
Dialog.Initialize (Base)
Dialog.Title = "Frutas de estación"
'set the search items
SearchTemplate.Initialize
Dim Items As List
Items.Initialize
Items.AddAll(Array As String("Banana", "Pera", "Manzana" ,"Uva", "Naranja", "Melon", "Kiwwi", "Damasco", "Sandia"))
Items.Sort(True)
SearchTemplate.SetItems(Items)
End Sub
Sub btnSearch_Click
SearchTemplate.SearchField.HintText = "Escriba la fruta ...."
textoBuscar = SearchTemplate.SearchField.TextField
'Refresca el Template
SearchTemplate.SearchField.Update
Wait For (Dialog.ShowTemplate(SearchTemplate, "", "", "Salir")) Complete (Result As Int)
If Result = XUI.DialogResponse_Positive Then
btnSearch.xLBL.Text = SearchTemplate.SelectedItem
End If
End Sub
Sub textoBuscar_TextChanged
Log(textoBuscar.Text)
End Sub
Thanks so much