Run Method when Preference is Updated
How would I add a listener so that when a preference is changed (i.e开发者_高级运维. CheckBoxPreference) some method is executed (i.e. Toast)
Preferences.java
public class Preferences extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
Main.java
[...]
SharedPreferences preferences;
preferences = PreferenceManager.getDefaultSharedPreferences(this);
[...]
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AdvancedPreferences.html
精彩评论