有没有办法迭代所有的偏好?
现在我正在询问每个偏好
private void doSomething( Preference p ) {
if( p instanceof PreferenceCategory || p instanceof PreferenceScreen ) {
PreferenceGroup pGroup = (PreferenceGroup) p;
int pCount = pGroup.getPreferenceCount();
for(int i = 0; i < pCount; i++) {
doSomething(pGroup.getPreference(i)); // recursive call
}
} else {
... process single preference ...
}
}
我想这样做:
int pCount = getTotalPreferenceCount();
for(int i = 0; i < pCount; i++) {
// process getFlatPreference(i);
}