Loading packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java +57 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.settingslib.widget; import android.annotation.StringRes; import android.content.Context; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.res.TypedArrayUtils; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; Loading Loading @@ -80,4 +82,59 @@ public class FooterPreference extends Preference { setKey(KEY_FOOTER); } } /** * The builder is convenient to creat a dynamic FooterPreference. */ public static class Builder { private Context mContext; private String mKey; private CharSequence mTitle; public Builder(@NonNull Context context) { mContext = context; } /** * To set the key value of the {@link FooterPreference}. * @param key The key value. */ public Builder setKey(String key) { mKey = key; return this; } /** * To set the title of the {@link FooterPreference}. * @param title The title. */ public Builder setTitle(CharSequence title) { mTitle = title; return this; } /** * To set the title of the {@link FooterPreference}. * @param titleResId The resource id of the title. */ public Builder setTitle(@StringRes int titleResId) { mTitle = mContext.getText(titleResId); return this; } /** * To generate the {@link FooterPreference}. */ public FooterPreference build() { final FooterPreference footerPreference = new FooterPreference(mContext); footerPreference.setSelectable(false); if (!TextUtils.isEmpty(mKey)) { footerPreference.setKey(mKey); } if (!TextUtils.isEmpty(mTitle)) { footerPreference.setTitle(mTitle); } return footerPreference; } } } Loading
packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java +57 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.settingslib.widget; import android.annotation.StringRes; import android.content.Context; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.res.TypedArrayUtils; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; Loading Loading @@ -80,4 +82,59 @@ public class FooterPreference extends Preference { setKey(KEY_FOOTER); } } /** * The builder is convenient to creat a dynamic FooterPreference. */ public static class Builder { private Context mContext; private String mKey; private CharSequence mTitle; public Builder(@NonNull Context context) { mContext = context; } /** * To set the key value of the {@link FooterPreference}. * @param key The key value. */ public Builder setKey(String key) { mKey = key; return this; } /** * To set the title of the {@link FooterPreference}. * @param title The title. */ public Builder setTitle(CharSequence title) { mTitle = title; return this; } /** * To set the title of the {@link FooterPreference}. * @param titleResId The resource id of the title. */ public Builder setTitle(@StringRes int titleResId) { mTitle = mContext.getText(titleResId); return this; } /** * To generate the {@link FooterPreference}. */ public FooterPreference build() { final FooterPreference footerPreference = new FooterPreference(mContext); footerPreference.setSelectable(false); if (!TextUtils.isEmpty(mKey)) { footerPreference.setKey(mKey); } if (!TextUtils.isEmpty(mTitle)) { footerPreference.setTitle(mTitle); } return footerPreference; } } }