Separator between PreferenceCategory

I know how to change the color of Headers inside 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));

    }
}

      

But I also want to change the separator between PreferenceCategory

and items below. I tried to grab the list and use the setDivider () method:

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

      

But this throws a NullPointerException due to what it cannot find list

in this view

. I know I can set this in an XML file and add this as a style, but I want to do it in java if possible. Any suggestions?

+3


source to share





All Articles