Lines Matching refs:preference
17 package android.preference;
33 * {@link Preference} objects. It is a base class for Preference objects that are
45 public abstract class PreferenceGroup extends Preference implements GenericInflater.Parent<Preference> {
47 * The container for child {@link Preference}s. This is sorted based on the
48 * ordering, please use {@link #addPreference(Preference)} instead of adding
51 private List<Preference> mPreferenceList;
62 mPreferenceList = new ArrayList<Preference>();
80 * Whether to order the {@link Preference} children of this group as they
81 * are added. If this is false, the ordering will follow each Preference
88 * @see Preference#setOrder(int)
107 public void addItemFromInflater(Preference preference) {
108 addPreference(preference);
112 * Returns the number of children {@link Preference}s.
113 * @return The number of preference children in this group.
120 * Returns the {@link Preference} at a particular index.
122 * @param index The index of the {@link Preference} to retrieve.
123 * @return The {@link Preference}.
125 public Preference getPreference(int index) {
130 * Adds a {@link Preference} at the correct position based on the
131 * preference's order.
133 * @param preference The preference to add.
134 * @return Whether the preference is now in this group.
136 public boolean addPreference(Preference preference) {
137 if (mPreferenceList.contains(preference)) {
142 if (preference.getOrder() == Preference.DEFAULT_ORDER) {
144 preference.setOrder(mCurrentPreferenceOrder++);
147 if (preference instanceof PreferenceGroup) {
150 ((PreferenceGroup)preference).setOrderingAsAdded(mOrderingAsAdded);
154 int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
159 if (!onPrepareAddPreference(preference)) {
164 mPreferenceList.add(insertionIndex, preference);
167 preference.onAttachedToHierarchy(getPreferenceManager());
170 preference.onAttachedToActivity();
179 * Removes a {@link Preference} from this group.
181 * @param preference The preference to remove.
182 * @return Whether the preference was found and removed.
184 public boolean removePreference(Preference preference) {
185 final boolean returnValue = removePreferenceInt(preference);
190 private boolean removePreferenceInt(Preference preference) {
192 preference.onPrepareForRemoval();
193 return mPreferenceList.remove(preference);
198 * Removes all {@link Preference Preferences} from this group.
202 List<Preference> preferenceList = mPreferenceList;
211 * Prepares a {@link Preference} to be added to the group.
213 * @param preference The preference to add.
214 * @return Whether to allow adding the preference (true), or not (false).
216 protected boolean onPrepareAddPreference(Preference preference) {
217 preference.onParentChanged(this, shouldDisableDependents());
222 * Finds a {@link Preference} based on its key. If two {@link Preference}
224 * returned (to retrieve the other preference with the same key, call this
225 * method on the first preference). If this preference has the key, it will
228 * This will recursively search for the preference into children that are
231 * @param key The key of the preference to retrieve.
232 * @return The {@link Preference} with the key, or null.
234 public Preference findPreference(CharSequence key) {
240 final Preference preference = getPreference(i);
241 final String curKey = preference.getKey();
244 return preference;
247 if (preference instanceof PreferenceGroup) {
248 final Preference returnedPreference = ((PreferenceGroup)preference)
260 * Whether this preference group should be shown on the same screen as its
264 * screen as this preference.
274 // Mark as attached so if a preference is later added to this group, we