I have a ListView with custom layout for its items and need to specify the separate background color for checked items using selector.
Here is selector for odd items:

```
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@android:color/black" />
    <item android:state_checked="true" android:drawable="@android:color/black" />
    <item android:state_selected="true" android:drawable="@color/red" />
    <item android:drawable="@android:color/white" />
</selector>

```

and here is selector for even items:

```
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@android:color/black" />
    <item android:state_checked="true" android:drawable="@android:color/black" />
    <item android:state_selected="true" android:drawable="@color/red" />
    <item android:drawable="@color/gray" />
</selector>

```

ListView item template looks like this:

```
<?xml version="1.0" encoding="utf-8"?>
<com.androidhub.core.CheckableLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="40dip">
    <TextView 
        android:text="TextView" 
        android:id="@+id/textView1" 
        android:layout_height="fill_parent" 
        android:layout_width="wrap_content" 
        android:gravity="center_vertical" 
        android:textColor="@color/list_item"></TextView>
</com.androidhub.core.CheckableLinearLayout>

```

The root element of list item is CheckableLinearLayout: <http://paste.org/pastebin/view/28711>

ListView has single choice mode (I also tried multiple choice mode but it also does not work for me)

```
public class MainActivity extends ListActivity {

    List<String> items = new ArrayList<String>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        items.add("test 1");
        items.add("test 2");
        items.add("test 3");
        items.add("test 4");
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        getListView().setAdapter(new TestAdapter(this, items));
        getListView().setBackgroundColor(getResources().
            getColor(android.R.color.white));
    }
}

```

In adapter for this ListView I call setChecked() method of CheckableLinearLayout but it does not change its color:

```
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View v = convertView;
    if(v == null) {
        v = inflater.inflate(R.layout.list_item, null);
    }

    if(position % 2 != 0) {
        v.setBackgroundResource(R.drawable.list_item_even);
    }
    else {
        v.setBackgroundResource(R.drawable.list_item_odd);
    }

    if(parent instanceof ListView) {
        ListView lv = (ListView)parent;
        if(v instanceof CheckableLinearLayout) {
            CheckableLinearLayout cll = (CheckableLinearLayout)v;
            cll.setChecked(lv.isItemChecked(position));
        }
    }

    return v;
}

```

What I'm doing wrong? I can see that **state\_pressed** item from selector works fine but **state\_checked** does not.
What will be the right approach to setup **state\_checked** background from XML, not from code?