Sub btnSearch_Click
Wait For (Dialog.ShowTemplate(SearchTemplate, "", "NEW", "CANCEL")) Complete (Result As Int)
If Result = XUI.DialogResponse_Positive Then
Dim str As String =SearchTemplate.Selecteditem
Msgbox2Async(""& str, "B4X Search Template Example","SELECT"," CANCEL","DELETE", Null, False)
Wait For Msgbox_Result (Result As Int)
If Result = DialogResponse.POSITIVE Then
If str<>"" Then
btnSearch.xLBL.Text = str
ToastMessageShow("" & str& " Selected",True)
Else
ToastMessageShow("Enter Something",True)
End If
else if Result=DialogResponse.NEGATIVE Then
If str<>"" Then
Log("size before delete: " & items2.Size)
btnSearch.xLBL.Text = "Search Dialog"
items2.RemoveAt(items2.IndexOf(str))
ToastMessageShow("" & str& " Deleted",True)
Log("size after delete: " & items2.Size)
Else
ToastMessageShow("Enter Something",True)
End If
End If
else if Result = XUI.DialogResponse_negative Then
Dim str As String =SearchTemplate.SearchField.text
If str <>"" Then
Dim sf As StringFunctions
sf.Initialize
Dim s As String= sf.Proper(str)
items2.Add(s)
items2.SortCaseInsensitive(True)
'File.writeList(File.DirDefaultExternal, "colors.txt",items)
SearchTemplate.SetItems(items2)
ToastMessageShow("" & str& " Added",True)
btnSearch.xLBL.Text = S
Else
ToastMessageShow("Enter Something",True)
End If
End If
End Sub