1. Download the #1 Android News App:   EarlyBird - News for Android
    Dismiss Notice

Force user to use one of the autocomplete options

Last Updated:

  1. ScotDiddle

    ScotDiddle Member

    Hello All,

    My business app requires specific items to be entered into EditText Fields. (Zip codes for the state of Virginia only, for example.) I am using an AutoCompleteTextView, and it is working as advertised. How do I ensure that only one of the items shown in the auto-complete drop-down list are allowed in the edit box field.


    Scot L. Diddle, Richmond VA

  2. jonbonazza

    jonbonazza Well-Known Member

    For this, you should be using a Spinner control instead of an EditText.
  3. ScotDiddle

    ScotDiddle Member

    jonbonazza, Thanks for the reply, but a spinner would be impractaical. Virginia has a lot of zip codes... Also, I have a bunch of String[] arrays where the AutoComplete value might be up to 80 characters or more... Spinner display would look awful and be hard to navigate in both instances.
    Any way to do what I want ?

    Thanks again.

    Scot L. Diddle, Richmond VA
  4. jonbonazza

    jonbonazza Well-Known Member

    As far as I know, there isn't. Best you can do is validate the input before submitting it.
    ScotDiddle likes this.
  5. ScotDiddle

    ScotDiddle Member


    Thanks, that's what I figured. Maybe after I become proficient in Java I will write my own extended class :)

    I am validating before using user-supplied values... Just good programming practice, and I have been practicing since 1980.


Share This Page