1. Download our Official Android App: Forums for Android!

Apps Force user to use one of the autocomplete options

Discussion in 'Android Development' started by ScotDiddle, Sep 11, 2012.

  1. ScotDiddle

    ScotDiddle Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    May 22, 2012

    May 22, 2012
    5
    0
    5
    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.

    Thanks,

    Scot L. Diddle, Richmond VA
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    For this, you should be using a Spinner control instead of an EditText.
     
  3. ScotDiddle

    ScotDiddle Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    May 22, 2012

    May 22, 2012
    5
    0
    5
    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 Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    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 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    May 22, 2012

    May 22, 2012
    5
    0
    5
    jonbonazza,

    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.

    Scot
     

Share This Page

Loading...