I implemented PreferenceManager.OnPreferenceTreeClickListener but my onPreferenceTreeClick() won’t proc

I am making a settings screen for my project with layout.
I want my last Preference object to be a clickable factory reset option for my settings.

In my XML this object looks like this:

<Preference
    app:key="reset"
    app:selectable="true"
    app:summary="Reset to factory settings"
    app:title="Reset" />

My overriden intefrace looks like this:

override fun onPreferenceTreeClick(preference: Preference?): Boolean {
    val key = preference!!.key
    return if (key == "reset") {
        Log.i(Tag, "Reset has proced")
        true
    } else false
}

My log just won’t proc and I don’t know why.

Can anyone help?

Source: Android Questions

LEAVE A COMMENT