的preference摘要只允许2行。 如果我想显示3行以上的总结。我能怎么做 ?
Summary of preference is allowed only 2 lines . If I want to display 3 lines or more in summary . How can I do ?
您可以通过扩展现有preference创建您 preference
类:
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);
}
}
然后在 preferences.xml
:
<com.your.package.name.LongSummaryCheckBoxPreference
android:key="@string/key"
android:title="@string/title"
android:summary="@string/summary"
... />
缺点是,你继承你需要3行汇总所有preference类型。
The drawback is that you need to subclass all preference types you need 3 lines summary for.