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
What is the bast way to handle DropDownPreference integer values #176
Labels
Comments
You can use pref value as the backing field of your value. object Settings : KotprefModel() {
private var internalMyPref: String by stringPref(key = "myPref")
var myPref: Int
get() = internalMyPref.toInt()
set(value) {
internalMyPref = value.toString()
}
} |
That's right. Thank you.
On October 21, 2019 12:57:13 AM UTC, Takao Chiba <notifications@github.com> wrote:
You can use pref value as the backing field of your value.
object Settings : KotprefModel() {
private var internalMyPref: String by stringPref(key = "myPref")
var myPref: Int
get() = internalMyPref.toInt()
set(value) {
internalMyPref = value.toString()
}
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#176?email_source=notifications&email_token=ADLIVV4D4SZXDPMZFSKYALDQPT46TA5CNFSM4JCRAJKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYYVDY#issuecomment-544311951>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADLIVV723DUIAQOUWXJLB4TQPT46TANCNFSM4JCRAJKA>.
|
Hi again, I don't suppose there is way to do above and observe with live-data. Am I correct? |
Hi, You are correct. Currently, Kotpref can't observe directly with LiveData. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a DropDownPreference with integer values. Android needs string-array for values to be used and that crates an issue where I have to define preference model member as
var myPref: String by stringPref
.Is there a correct way of of accessing this preference apart from converting it to Int in my code?
The text was updated successfully, but these errors were encountered: