diff options
Diffstat (limited to 'core/java/android/preference/Preference.java')
| -rw-r--r-- | core/java/android/preference/Preference.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java index d9c749a65d0f..4d14277be9c1 100644 --- a/core/java/android/preference/Preference.java +++ b/core/java/android/preference/Preference.java @@ -82,6 +82,7 @@ import java.util.Set; * @attr ref android.R.styleable#Preference_defaultValue * @attr ref android.R.styleable#Preference_shouldDisableView * @attr ref android.R.styleable#Preference_recycleEnabled + * @attr ref android.R.styleable#Preference_singleLineTitle */ public class Preference implements Comparable<Preference> { /** @@ -133,6 +134,7 @@ public class Preference implements Comparable<Preference> { private boolean mDependencyMet = true; private boolean mParentDependencyMet = true; private boolean mRecycleEnabled = true; + private boolean mSingleLineTitle = true; /** * @see #setShouldDisableView(boolean) @@ -296,6 +298,10 @@ public class Preference implements Comparable<Preference> { case com.android.internal.R.styleable.Preference_recycleEnabled: mRecycleEnabled = a.getBoolean(attr, mRecycleEnabled); break; + + case com.android.internal.R.styleable.Preference_singleLineTitle: + mSingleLineTitle = a.getBoolean(attr, mSingleLineTitle); + break; } } a.recycle(); @@ -597,6 +603,7 @@ public class Preference implements Comparable<Preference> { if (!TextUtils.isEmpty(title)) { titleView.setText(title); titleView.setVisibility(View.VISIBLE); + titleView.setSingleLine(mSingleLineTitle); } else { titleView.setVisibility(View.GONE); } @@ -903,6 +910,27 @@ public class Preference implements Comparable<Preference> { } /** + * Sets whether to constrain the title of this Preference to a single line instead of + * letting it wrap onto multiple lines. + * + * @param singleLineTitle set {@code true} if the title should be constrained to one line + */ + public void setSingleLineTitle(boolean singleLineTitle) { + mSingleLineTitle = singleLineTitle; + notifyChanged(); + } + + /** + * Gets whether the title of this preference is constrained to a single line. + * + * @see #setSingleLineTitle(boolean) + * @return {@code true} if the title of this preference is constrained to a single line + */ + public boolean isSingleLineTitle() { + return mSingleLineTitle; + } + + /** * Returns a unique ID for this Preference. This ID should be unique across all * Preference objects in a hierarchy. * |
