Merge "Extend single line summary preference to multi line."
This commit is contained in:
committed by
Android (Google) Code Review
commit
cf162d1291
@@ -15,19 +15,36 @@
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.TextUtils.TruncateAt;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* A preference whose summary text will only span one single line.
|
||||
*/
|
||||
public class SingleLineSummaryPreference extends Preference {
|
||||
public class FixedLineSummaryPreference extends Preference {
|
||||
|
||||
public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
|
||||
private int mSummaryLineCount;
|
||||
|
||||
public FixedLineSummaryPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FixedLineSummaryPreference,
|
||||
0, 0);
|
||||
if (a.hasValue(R.styleable.FixedLineSummaryPreference_summaryLineCount)) {
|
||||
mSummaryLineCount = a.getInteger(
|
||||
R.styleable.FixedLineSummaryPreference_summaryLineCount, 1);
|
||||
} else {
|
||||
mSummaryLineCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSummaryLineCount(int count) {
|
||||
mSummaryLineCount = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +52,8 @@ public class SingleLineSummaryPreference extends Preference {
|
||||
super.onBindViewHolder(holder);
|
||||
TextView summary = (TextView) holder.findViewById(android.R.id.summary);
|
||||
if (summary != null) {
|
||||
summary.setSingleLine();
|
||||
summary.setMinLines(mSummaryLineCount);
|
||||
summary.setMaxLines(mSummaryLineCount);
|
||||
summary.setEllipsize(TruncateAt.END);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user