Preference change handler.

master
Tomasz Półgrabia 2016-10-09 11:07:53 +02:00
parent 99d9e5ab31
commit 193972d461
1 changed files with 16 additions and 0 deletions

View File

@ -1,16 +1,32 @@
package pl.tpolgrabia.urbanexplorer.fragments; package pl.tpolgrabia.urbanexplorer.fragments;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.widget.Toast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.tpolgrabia.urbanexplorer.R; import pl.tpolgrabia.urbanexplorer.R;
public class SettingsFragment extends PreferenceFragment { public class SettingsFragment extends PreferenceFragment {
private Logger lg = LoggerFactory.getLogger(SettingsFragment.class);
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.urban_expl_settings); addPreferencesFromResource(R.xml.urban_expl_settings);
getPreferenceScreen().setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// TODO handle changing preference
lg.info("Preference {} has changed its value to {}",
preference,
newValue);
return true;
}
});
} }
} }