Android AutoCompleteEditText Searching Application Tutorial using Basic4Android
Submitted by donbermoy on Tuesday, January 28, 2014 - 20:35.
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.
Declare first your variable in the Sub_Global like this:
- Sub Globals
- 'These global variables will be redeclared each time the activity is created.
- 'These variables can only be accessed from this module.
- Dim auto1 As AutoCompleteEditText
- End Sub
Note:
auto1 - our variable used as a name for our AutoCompleteEditText Here's the full code for this tutorial:- Sub Process_Globals
- 'These global variables will be declared once when the application starts.
- 'These variables can be accessed from all modules.
- End Sub
- Sub Globals
- 'These global variables will be redeclared each time the activity is created.
- 'These variables can only be accessed from this module.
- Dim auto1 As AutoCompleteEditText
- 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("tutorial")
- auto1.Initialize("auto1")
- Activity.AddView(auto1,0dip,10dip,300dip,70dip)
- Dim nomi () As String
- 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
- auto1.SetItems(nomi) 'our auto1 here is the variable for AutoCompleteEditText in which it has now the values set in "nomi"
- End Sub
- Sub Activity_Resume
- End Sub
- Sub Activity_Pause (UserClosed As Boolean)
- 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/BermzISwareAdd new comment
- 162 views