9
I have a listView. custom_listitem1.xml is used for the items display in the list. Now i want to set Selector based color resource(list_selector_color.xml) for the background of the item.
custom_listitem1.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
android:background="@color/list_selector_color"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight"/>
list_selector_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
but it is giving following errors.....
06-06 18:38:19.422: ERROR/AndroidRuntime(18603): Uncaught handler: thread main exiting due to uncaught exception
06-06 18:38:19.445: ERROR/AndroidRuntime(18603): android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
06-06 18:38:19.445: ERROR/AndroidRuntime(18603): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
06-06 18:38:19.445: ERROR/AndroidRuntime(18603): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-06 18:38:19.445: ERROR/AndroidRuntime(18603): at android.view.LayoutInflater.createViewFromTag