views:

59

answers:

0

I'm working on an Android widget which essentially places a button on the homescreen. The button uses a selector in order to show a default state and a pressed state. Each state has its own image, as you'll see in the code below.

I already have code to change the hue of an image and return a new StateListDrawable for use in the ImageButton.

My question: How do I actually apply the StateListDrawable to the ImageButton's android:background attribute using the RemoteView?

Here is the XML source for the widget layout:

<LinearLayout
    android:id="@+id/LinearLayout01"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content">
    <ImageButton
        android:id="@+id/ImageButton01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:background="@drawable/buttonselector" />
</LinearLayout>

Instead of using the hardcoded "@drawable/buttonselector" it needs to be the dynamic selector I'm generating.