Summary of preference is allowed only 2 lines . If I want to display 3 lines or more in summary . How can I do ?
You can create you Preference
class by extending any existing preference:
public class LongSummaryCheckboxPreference extends CheckboxPreference
{
public LongSummaryCheckboxPreference(Context ctx, AttributeSet attrs, int defStyle)
{
super(ctx, attrs, defStyle);
}
public LongSummaryCheckboxPreference(Context ctx, AttributeSet attrs)
{
super(ctx, attrs);
}
@Override
protected void onBindView(View view)
{
super.onBindView(view);
TextView summary= (TextView)view.findViewById(android.R.id.summary);
summary.setMaxLines(3);
}
}
And then in preferences.xml
:
<com.your.package.name.LongSummaryCheckBoxPreference
android:key="@string/key"
android:title="@string/title"
android:summary="@string/summary"
... />
The drawback is that you need to subclass all preference types you need 3 lines summary for.
来源:https://stackoverflow.com/questions/6729484/android-preference-summary-how-to-set-3-lines-in-summary