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

ListPreference: Use array.xml resource? #12

Open
obama opened this issue Sep 17, 2024 · 1 comment
Open

ListPreference: Use array.xml resource? #12

obama opened this issue Sep 17, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@obama
Copy link

obama commented Sep 17, 2024

Is there a easy way to load value / label pairs from arrays.xml?

can you maybe add it to the example?

in the old XML preferences you had two parameters:
app:entries="@array/setting_entries"
app:entryValues="@array/setting_values"

now i need to create some kind of object that will return its value and offer a toString() to write the "entries"?

@zhanghai
Copy link
Owner

You can create a helper for loading the resources, and then do a reverse lookup for finding the index of the value and then get the entry name from the index. I didn't create such a helper because I'd like to make the library Compose Multi-Platform one day so I wanted to avoid an API specific to Android. Plus it's relatively straightforward to write.

@zhanghai zhanghai self-assigned this Sep 17, 2024
@zhanghai zhanghai added the question Further information is requested label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants