Android Question EditText to select an item from a spinner

Beja

Expert
Licensed User
Longtime User
The GetItem method of spinner requires the item index.. but I want to supply the item text instead.. is that possible?
If the items are few then I can use the View's drop-down list.. but if the list is long then I want the user to also enter
the item text directly in an EditTextView and on Button1_Click the item should be selected in the Spinner.
The error in entering the value is very limited since it is only for the customer ID number.
(Pseudo code)
Sub Button1_Click
Spinner1 = EditText1 IF the value in EditText1 matches an item in Spinner1
End Sub

Thanks in advance
 

Beja

Expert
Licensed User
Longtime User
Hi Klaus and thanks for the help..
I am getting the following error:
ArrayIndexOutOfBoundsException

a small test project attached..
 

Attachments

  • spinner_edittext.zip
    7.5 KB · Views: 269
Upvote 0

Beja

Expert
Licensed User
Longtime User
Thanks Klaus,
Perfect!
I always said you are for it.
tiny typo: "SelectedIndex" instead of "SelectIndex"
Now I will play with it to make it case and leading-trailing space tolerant.
 
Last edited:
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
As I'm beginning to use spinner in an app I red this.
Thanks , teamwork at it's best.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…