I have a PrefrenceActivity
which includes DialogPreference
with my custom layout (edittext and checkbox).
When my DialogPrefernce is called for the first time, its onSetInitValue
is called, I get values from SharedPreferences and then in onBindDialogView
I update my edittext and checkbox.
Then I change the edittext value, (positive) close the dialog and save the value to SharedPreferences in onDialogClosed
.
Great work so far.
Unfortunately, when I open the dialog again, the onSetInitValue
is not called and the values remains unchanged. I've found out the onSetInitValues is called only after closing the PrefrenceActivity and reopening it again.
I hacked it using a flag (if onSetInitValues is called I set flag which I check in onBindDialogView - if it's not set I get values from SharedPreferences).
This is ugly solution. Is there a way to "rerender" the dialog or call onSetInitValues
when the Preferences wasn't closed?