package me.brysonsteck.wiimmfiwatcher.settings; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import me.brysonsteck.wiimmfiwatcher.R; public class SettingsMainFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootkey) { super.onCreate(savedInstanceState); setPreferencesFromResource(R.xml.preferences, rootkey); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ListPreference mListPreference = (ListPreference) getPreferenceManager().findPreference("preference_key"); mListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // your code here return true; } }); return inflater.inflate(R.layout.main_settings_fragment, container, false); } }