I have write a multi-level Preferences in program with xml File. and i want to know how to return to the previous level without press the back button. how to write some code
I had the same problem and solve it thanks to Xuelong and getDialog() but without needing to manage onPreferenceTreeClick().
You will then return from where you came from.
Here is a epurated example :
Xml file :
Java file :
public class ParanoidPreferenceManager extends PreferenceActivity {
ListPreference contactList;
EditTextPreference foo1;
PreferenceScreen mySubScreenKey;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Load XML preference file
addPreferencesFromResource(R.xml.preferences);
contactList = (ListPreference) findPreference("contactList");
foo1= (EditTextPreference) findPreference("foo1");
screenContact = (PreferenceScreen) findPreference("screenAddContact");
foo1.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
mySubScreenKey.getDialog().dismiss();
return false;
}
});
}
}
That's it
Sorry for presentation, this is my first post on this site.
Bye dudes