2011-07-18 5 views

答えて

21

あなたはあなたの既存の優先順位を拡張することにより、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行に必要なすべての好みのタイプをサブクラス化する必要があるということですのための要約。

+1

投稿に感謝します – kikura

+1

ありがとう!これは私の魅力のように働いた。 –

+1

非常に良い。よく働く! –

関連する問題