3

内の見出しの色を変更する方法を知っていPreferenceCategoryます。

public class PreferenceCategory1 extends PreferenceCategory {
    public PreferenceCategory1(Context context) {
        super(context);
    }

    public PreferenceCategory1(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PreferenceCategory1(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        TextView titleView = (TextView) view.findViewById(android.R.id.title);
        titleView.setTextColor(Color.rgb(238, 120, 30));

    }
}

PreferenceCategoryしかし、とその下の要素の間の Divider も変更したいと思います。リストビューを取得して setDivider() メソッドを使用しようとしました:

  ListView v = (ListView)view.findViewById(android.R.id.list);
  v.setDivider(new ColorDrawable(Color.rgb(238, 120, 30)));

しかし、 this で が見つからないという事実により、これにより NullPointerException が発生しlistますview。これをxmlファイルに設定してスタイルとして追加できることは承知していますが、可能であればJavaでこれを行いたいです。助言がありますか?

4

0 に答える 0