Hi,

I am trying to customize background drawable for Gallery widget in android.
So I took the Gallery1.java in APIDemo and try changing the background
drawable of Gallery.

In Gallery1.java, I add:
        // Reference the Gallery view
        Gallery g = (Gallery) findViewById(R.id.gallery);

        g.setFocusable(true);
        g.setFocusableInTouchMode(true);
        g.setBackgroundResource(R.drawable.gallery_background_1);


In the gallery_background_1.xml, I have
<selector xmlns:android="http://schemas.android.com/apk/res/android";>
    <item android:state_pressed="true" android:drawable="@drawable/blue_box" />
    <item android:drawable="@drawable/red_box" />
</selector>

When I run in the emulator, I do see the red color as the background
of the gallery.
But I never see it changes to blue as I pressed the gallery.

Can you please tell me what am I missing?

Thank you for your help.

Here is the red_box and blue_box drawable:
blue_box.xml:

 <shape xmlns:android="http://schemas.android.com/apk/res/android";>
    <solid android:color="#1e0000ff"/>
    <padding android:left="1dp" android:top="1dp"
            android:right="1dp" android:bottom="1dp" />
</shape>

red_box.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android";>
    <solid android:color="#1eff0000"/>
    <padding android:left="1dp" android:top="1dp"
            android:right="1dp" android:bottom="1dp" />
</shape>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to