Skip to content
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

How to pre-select a certain item? #170

Closed
vtomic85 opened this issue Mar 18, 2022 · 2 comments
Closed

How to pre-select a certain item? #170

vtomic85 opened this issue Mar 18, 2022 · 2 comments

Comments

@vtomic85
Copy link

Hi,

I am using this picker with two options in the list (let's call them "A" and "B"). Initially, the default option is "A". When I switch to "B", I would like the picker to "remember" it somehow, so when I open it again, I would like the option "B" to be preselected. Is this possible?
Thanks.

@kekag
Copy link

kekag commented Apr 2, 2022

The selecteds attribute on the Picker can control the default value. Just provide the indices of whichever options you want the default to be, e.g.:

selecteds: <int>[
  1, // the second option will be selected
]

Otherwise, if you're using a NumberPickerAdapter, the NumberPickerColumn object has an initValue attribute which provides this same functionality.

@justintoth
Copy link

I can confirm that passing the selected index in with the "selecteds" property works. This should probably be closed.

@yangyxd yangyxd closed this as completed Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants