Home | History | Annotate | Download | only in preference

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>();
76 * Whether to order the {@link Preference} children of this group as they
77 * are added. If this is false, the ordering will follow each Preference
84 * @see Preference#setOrder(int)
103 public void addItemFromInflater(Preference preference) {
104 addPreference(preference);
108 * Returns the number of children {@link Preference}s.
109 * @return The number of preference children in this group.
116 * Returns the {@link Preference} at a particular index.
118 * @param index The index of the {@link Preference} to retrieve.
119 * @return The {@link Preference}.
121 public Preference getPreference(int index) {
126 * Adds a {@link Preference} at the correct position based on the
127 * preference's order.
129 * @param preference The preference to add.
130 * @return Whether the preference is now in this group.
132 public boolean addPreference(Preference preference) {
133 if (mPreferenceList.contains(preference)) {
138 if (preference.getOrder() == Preference.DEFAULT_ORDER) {
140 preference.setOrder(mCurrentPreferenceOrder++);
143 if (preference instanceof PreferenceGroup) {
146 ((PreferenceGroup)preference).setOrderingAsAdded(mOrderingAsAdded);
150 int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
155 if (!onPrepareAddPreference(preference)) {
160 mPreferenceList.add(insertionIndex, preference);
163 preference.onAttachedToHierarchy(getPreferenceManager());
166 preference.onAttachedToActivity();
175 * Removes a {@link Preference} from this group.
177 * @param preference The preference to remove.
178 * @return Whether the preference was found and removed.
180 public boolean removePreference(Preference preference) {
181 final boolean returnValue = removePreferenceInt(preference);
186 private boolean removePreferenceInt(Preference preference) {
188 preference.onPrepareForRemoval();
189 return mPreferenceList.remove(preference);
194 * Removes all {@link Preference Preferences} from this group.
198 List<Preference> preferenceList = mPreferenceList;
207 * Prepares a {@link Preference} to be added to the group.
209 * @param preference The preference to add.
210 * @return Whether to allow adding the preference (true), or not (false).
212 protected boolean onPrepareAddPreference(Preference preference) {
214 preference.setEnabled(false);
221 * Finds a {@link Preference} based on its key. If two {@link Preference}
223 * returned (to retrieve the other preference with the same key, call this
224 * method on the first preference). If this preference has the key, it will
227 * This will recursively search for the preference into children that are
230 * @param key The key of the preference to retrieve.
231 * @return The {@link Preference} with the key, or null.
233 public Preference findPreference(CharSequence key) {
239 final Preference preference = getPreference(i);
240 final String curKey = preference.getKey();
243 return preference;
246 if (preference instanceof PreferenceGroup) {
247 final Preference returnedPreference = ((PreferenceGroup)preference)
259 * Whether this preference group should be shown on the same screen as its
263 * screen as this preference.
273 // Mark as attached so if a preference is later added to this group, we