安卓preference总结。如何设置在总结3条线? [英] Android preference summary . How to set 3 lines in summary?

查看:128
本文介绍了安卓preference总结。如何设置在总结3条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的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.

这篇关于安卓preference总结。如何设置在总结3条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆