Android AutoCompleteEditText Searching Application Tutorial using Basic4Android

This is my first tutorial for using controls in Basic4Android. We have to discuss first the AutoCompleteEditText with Searching Application. AutoCompleteEditText is a control in basic4Android that is an editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with. Here, we will begin the tutorial. First, you need to create one AutoCompleteEditText and named it "auto1". Next, named your layout name as "tutorial". Make the abstract designer like this below. image Declare first your variable in the Sub_Global like this:
  1. Sub Globals
  2.         'These global variables will be redeclared each time the activity is created.
  3.         'These variables can only be accessed from this module.
  4.         Dim auto1 As AutoCompleteEditText
  5. End Sub

Note:

auto1 - our variable used as a name for our AutoCompleteEditText Here's the full code for this tutorial:
  1. Sub Process_Globals
  2.         'These global variables will be declared once when the application starts.
  3.         'These variables can be accessed from all modules.
  4.  
  5. End Sub
  6.  
  7. Sub Globals
  8.         'These global variables will be redeclared each time the activity is created.
  9.         'These variables can only be accessed from this module.
  10.         Dim auto1 As AutoCompleteEditText
  11.        
  12.                
  13. End Sub
  14.  
  15. Sub Activity_Create(FirstTime As Boolean)
  16.         'Do not forget to load the layout file created with the visual designer. For example:
  17.                 Activity.LoadLayout("tutorial")
  18.                 auto1.Initialize("auto1")
  19.                 Activity.AddView(auto1,0dip,10dip,300dip,70dip)
  20.                 Dim nomi () As String
  21.                 nomi = Array As String( "angela", "andrea", "angelo", "alberto", "carlo", "Clotilde", "filippo", "giorgio", "lyndon","novee") 'I declare the values of array to be in the EditText
  22.                 auto1.SetItems(nomi) 'our auto1 here is the variable for AutoCompleteEditText in which it has now the values set in "nomi"
  23.  
  24. End Sub
  25.  
  26. Sub Activity_Resume
  27.        
  28. End Sub
  29.  
  30. Sub Activity_Pause (UserClosed As Boolean)
  31.        
  32. End Sub

Note:

Activity.LoadLayout("tutorial") - a syntax used to load the main form of the UI in the visual designer. tutorial was our file name for the abstract designer that we created a while ago. Activity.AddView(auto1,0dip,10dip,300dip,70dip) - a syntax for adding a view to the activity with our auto1 inside. 0dip is the size of the left, 10dip is the size of the top, 300dip as our width, and 70dip as our height. Dim nomi () As String - we initialized nomi here as our array variable for our string. nomi = Array As String( "angela", "andrea", "angelo", "alberto", "carlo", "Clotilde", "filippo", "giorgio","lyndon","novee") -our nomi as string has now an array values of names.I declare the values of array to be in the EditText of the application. auto1.SetItems(nomi) - nomi that has now the values of names are now in the Textbox of auto1. Thus, if the user will input a string, then it will be in the textbox alphabetically. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer If you have some queries, feel free to contact the number or e-mail below. Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment