• We just launched and are currently in beta. Join us as we build and grow the community.

Android AutoCompleteEditText Searching Application Tutorial using Basic4Android

Bjachi

Ledger Architect
B Rep
0
0
0
Rep
0
B Vouches
0
0
0
Vouches
0
Posts
78
Likes
53
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 500 XP
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.

image1_0.png


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. End

    Sub

  5. Sub

    Globals
  6. 'These global variables will be redeclared each time the activity is created.
  7. 'These variables can only be accessed from this module.
  8. Dim

    auto1 As

    AutoCompleteEditText


  9. End

    Sub

  10. Sub

    Activity_Create(FirstTime As

    Boolean

    )
  11. 'Do not forget to load the layout file created with the visual designer. For example:
  12. Activity.LoadLayout("tutorial"

    )
  13. auto1.Initialize("auto1"

    )
  14. Activity.AddView(auto1,0dip,10dip,300dip,70dip)
  15. Dim

    nomi () As

    String
  16. 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
  17. auto1.SetItems(nomi) 'our auto1 here is the variable for AutoCompleteEditText in which it has now the values set in "nomi"

  18. End

    Sub

  19. Sub

    Activity_Resume

  20. End

    Sub

  21. Sub

    Activity_Pause (UserClosed As

    Boolean

    )

  22. 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


Download
You must upgrade your account or reply in the thread to view hidden text.
 

449,193

322,229

322,238

Top