Hi. I'm having some problems with using listpreference.setValue or setIndexValue.
None of the methods that I need to alter the values of a listpreference programmatically doesn't seem to be available.
My class extends Preferencefragmentcompat
Thanks
Stefan
t
tseisel
07/24/2019, 4:36 PM
Sorry, I haven't noticed how your question was related to Kotlin.
ListPreference
has
setValue(String)
but not
setIndexValue
(it is named
setValueIndex(Int)
).
In Kotlin, when a class has 2 methods like the following :
Foo getFoo()
,
setFoo( Foo f)
, Kotlin converts it to a property, so you can directly write
obj.foo = ...
instead of
obj.setFoo(...)
.
That's the case for `ListPreference`: it has both
getValue()
and
setValue(String)
, thus the IDE suggests you "value" instead of "setValue(String)".
tseisel
07/24/2019, 4:37 PM
If you are still unable to find those methods on
ListPreference
, maybe you could share some code ?
s
Stefan
07/24/2019, 4:42 PM
Thank you for that, I'm still pretty new at kotlin and it's still a bit confusing.
I'm unable to get anything other than setDefaultValue.
I'll try to jot down some code.