-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetSelection not working. #129
Comments
**** UPDATE***** I still wish there was some functionality that did this already or better yet something much more clean. |
How did you set the selection on the spinner exactly ? |
For me the solution was to put the variable you want it to initialize to as the text programatically: |
`ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, testArr);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
isBuying.setAdapter(adapter);
isBuying.setSelection(1);
`
will not work but the regular spinner
`isRenting = findViewById(R.id.rentingSpinner);
isRenting.setAdapter(adapterYesNo);
isRenting.setSelection(1);`
does work
The material spinner is set up correctly in the layout file. There is a hint associated with both spinners. The material spinner stays at the "hint" selection where the regular spinner is set to "No" which is position 1 in the array. I know I am using an array-string resource only for the regular spinner and I am converting that resource to an actual array for the material spinner.
Nothing I try seems to work.
Is there a work-around for setting the position in these "material spinners" it is not just this use of it, it is all!
The text was updated successfully, but these errors were encountered: