I have an adapter that returns the following layout as one of the
views,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/date_selector_1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:background="@drawable/date_selector_bg"
>
<TextView
android:id="@+id/label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:textSize="20.0sp"
android:textColor="@color/solid_white"
/>
<ImageView
android:id="@+id/left_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/arr_left"
/>
<ImageView
android:id="@+id/right_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/arr_right"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/left_icon"
android:src="@drawable/hor_separator"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/right_icon"
android:src="@drawable/hor_separator"
/>
</RelativeLayout>
This items behaves as a header row with two buttons that are clickable
(one on right and one on left). These two buttons (images views) have
the following drawable that determines the image based on state,
arr_left.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@drawable/arr_left_selected" />
<item
android:drawable="@drawable/arr_left_disabled" />
</selector>
arr_right.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@drawable/arr_right_selected" />
<item
android:drawable="@drawable/arr_right_disabled" />
</selector>
In my code I set the left_icon and right_icon to enabled or disabled
based on data and I expected the imageview to correctly select the
image based on the states in the xml. To my utter frustration, the
disabled images NEVER appears. I know the left and right imageviews
are correctly being set to enabled and disabled because the
onclicklisteners are called or not called consistent with the state of
the view. I just cannot understand why the selector is not selecting
the correct state images... I know I can write code to force the
imageview to display the correct image but I am giving up alot of
flexibility in the future if I want to change out the images the
selector points to. I would really appreciate any advice on this
problem... my concern is that the RelativeLayout is a view in a
ListView and that the state of that view is somehow confusing the
StateListDrawable for the images.
Mark.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.